SlideShare ist ein Scribd-Unternehmen logo
1 von 30
INTRODUCTION TOINTRODUCTION TO
ASSET MANAGEMENTASSET MANAGEMENT
IN XOOPS CMS ENVIRONMENTIN XOOPS CMS ENVIRONMENT
XOOPS 2.6.0XOOPS 2.6.0
Education SeriesEducation Series
Richard Griffith
XOOPS Core Team Leader
April 2014© 2014 XOOPS Foundation www.xoops.org
2
© 2014 XOOPS Foundation www.xoops.org
ASSETS
Most of the focus in XOOPS asset management
is on stylesheet and script assets.
Most of the focus in XOOPS asset management
is on stylesheet and script assets.
A web page
consists of a base
HTML document
and any additional
files it may include,
such as
stylesheets,
scripts, images and
fonts. We will refer
to these additional
files as assets.
HTML
Text
Images
Media
HTML
Text
Images
Media
CSS
Page
layout
Text styles
CSS
Page
layout
Text styles
JS, PHP,etc
Scripts
Database
Interraction
JS, PHP,etc
Scripts
Database
Interraction
Content FunctionsStyles
+ +
3
© 2014 XOOPS Foundation www.xoops.org
Assets are a very
important part of the
user experience.
For today's rich, highly
interactive web
applications, the asset
performance may be
more significant than the
backend application and
database performance.
ASSETS ARE VALUABLE
Source: http://www.stevesouders.com/
4
© 2014 XOOPS Foundation www.xoops.org
ASSET PERFORMANCE FACTORS
Asset size
Number of files
Latency
● Network speed
 Connection set up an tear down
 Transfer rate
 Currency limits
● Client capacity
 Processing power/load
 Memory
 Cache speed
5
© 2014 XOOPS Foundation www.xoops.org
MANAGEMENT STRATEGIES
Minimize file sizes
Combine files to reduce network
connections
Serve assets as static files to
maximize caching
Avoid concurrency bottlenecks
●Assets that include other assets when
loaded
6
© 2014 XOOPS Foundation www.xoops.org
DEVELOPMENT VS. DEPLOYMENT
Develop / Debug
●Easy to read and
edit is essential
●Separate files are
easier to work with
and my come from
different sources
Deployment Focus
●Eliminate formatting
and whitespace
●Combine files to
eliminate latency
7
© 2014 XOOPS Foundation www.xoops.org
SOLVED WITH ASSET MANAGEMENT
Develop / Debug
●Easy to read and
edit is essential
●Separate files are
easier to work with
Asset management solves the
development vs. deployment
dilemma by using the exact same
sources for both needs.
Asset management solves the
development vs. deployment
dilemma by using the exact same
sources for both needs.
Deployment Focus
●Eliminate formatting
and whitespace
●Combine files to
eliminate latency
8
© 2014 XOOPS Foundation www.xoops.org
THE BASICS
Specify a file or set of files as an asset
Specify filters to apply to that asset
Create a static file from the asset for
the browser to load which :
●Contains the content of all the specified files
●Has all the specified filters applied
●Is transferred as a single unit
Asset Management allows you to:
9
© 2014 XOOPS Foundation www.xoops.org
XOOPS Asset Management is built on
Assetic, by Kris Wallsmith. For a
deeper understanding of some of the
concepts, review the documentation
available at:
https://github.com/kriswallsmith/assetic
THE BASICS - CONTINUED
10
© 2014 XOOPS Foundation www.xoops.org
THE BASICS - FILES
An asset can be a set of script or
stylesheet files, not both
An asset is defined by an array of file
specifications
A file can be specified by a fully
qualified filesystem name, or by a
path resolvable by the XOOPS path()
function
A file specification can also be a
wildcard pattern
11
© 2014 XOOPS Foundation www.xoops.org
XOOPS Asset Management comes configured
with a subset of the possible Assetic filters.
One major criteria for the selection of these
filters is they are all implemented in PHP and
require no additional binary packages to be
installed on the server. These filters are
portable and will be available for use where
ever XOOPS is installed.
Filters are specified as a string of comma
separated filter names. A filter name can be
preceded with a question mark (“?”) to turn it
off during debugging.
THE BASICS - FILTERS
12
© 2014 XOOPS Foundation www.xoops.org
THE BASICS–FILTERS-CONTINUED
Filter Name Assetic Filter Name Description
cssembed PhpCssEmbedFilter embeds image data in your
stylesheets
cssimport CssImportFilter inlines imported stylesheets
cssmin CssMinFilter minifies CSS
cssrewrite CssRewriteFilter fixes relative URLs in CSS
lessphp LessphpFilter Complile LESS to CSS
scssphp ScssphpFilter Compile SCSS to CSS
jsmin JSMinFilter minifies Javascript
These are the available filters :
13
© 2014 XOOPS Foundation www.xoops.org
THE BASICS–FILTERS-CONTINUED
If no filters are specified, default
filters will be applied.
● Stylesheets
– 'cssimport,cssembed,?cssmin'
● Javascript
– '?jsmin'
14
© 2014 XOOPS Foundation www.xoops.org
ASSETS LOCATION : CORE
● Managed assets are stored in the
“assets” directory in the XOOPS web
root
– stylesheets in css sub-directory
– scripts in js sub-directory
● These managed directories can be
cleared, and contents will be
recreated as needed
● Other subdirectories, such as fonts,
are managed differently
15
© 2014 XOOPS Foundation www.xoops.org
ASSETS LOCATION : MODULES
● Module's Assets are
also placed in an
“assets” folder, similar
to Core
● In order to take
advantage of Assetic,
current modules should
convert to this folder
structure
16
© 2014 XOOPS Foundation www.xoops.org
LAZY MANAGEMENT
● Each page load specifies the set of assets
it needs
● The lists of files, modification times, and
filters to apply are used to build unique
asset names
● If the static file with that name does not
exist, the asset files are processed and
filtered, and the static file is created
● There are no separate formula extraction
or preprocessing steps needed
17
© 2014 XOOPS Foundation www.xoops.org
EXISTING FUNCTIONS
XOOPS has historically provided two
methods in the XoopsTheme class to
deal with assets:
● addScript($url)
● addStylesheet($url)
* Note that these methods expect
URLs, not filesystem paths.
18
© 2014 XOOPS Foundation www.xoops.org
NEW ASSET FUNCTION
The XoopsTheme class has been expanded
to better manage assets. The following
methods are available:
● addScriptAssets($assets, $filters)
● addStylesheetAssets($assets, $filters)
● addBaseScriptAssets($assets)
● addBaseStylesheetAssets($assets)
● setNamedAsset($name, $assets, $filters)
19
© 2014 XOOPS Foundation www.xoops.org
addScriptAssets &
addStylesheetAssets
● Accept an array of one or more
asset file specifications
● Optionally accept a string of comma
separated filter names
● Result in combining and filtering
the assets, then adding the URL for
the created static asset file to the
same lists used by addScript() and
addStylesheet()
20
© 2014 XOOPS Foundation www.xoops.org
addBaseScriptAssets &
addBaseStylesheetAssets
● Accept an array of one or more
asset file specifications
● Accumulate asset files in separate
lists, similar to addScript() and
addStylesheet()
● Assets are processed using default
filters and the resulting static file
URL is added to the top of
respective list in the page headers:
<{$xoops_module_header}>
21
© 2014 XOOPS Foundation www.xoops.org
BASE ASSETS
● Core uses the base assets for common
system wide assets, such as jQuery,
jQueryUI, locale and Bootstrap assets
● Themes can add to the base assets using
theme_onload.php
● Modules may want to add their common
assets to the base asset
● Browser cache use is improved if the same
base asset definition is used for many
pages
22
© 2014 XOOPS Foundation www.xoops.org
setNamedAsset
● Accepts a unique asset name
● Accepts an array of one or more
asset file specifications
● Optionally accepts a string of
comma separated filter names
● Results in creating an asset
reference that can be specified in
asset arrays in place of a file
specification
23
© 2014 XOOPS Foundation www.xoops.org
NAMED ASSETS
● Named assets allow symbolic reference
to commonly used assets (i.e. “jquery”)
● Named assets can be given additional
filters
● Using setNamedAsset does not create the
asset, it just records the name and
definition
● To use an asset named “jquery” include
an asset name of “@jquery” in an asset
list
24
© 2014 XOOPS Foundation www.xoops.org
SMARTY ASSETS TAG
The Smarty block plugin allows assets
to be defined in templates. Full
syntax:
<{assets
assets="(file specifications, comma separated)”
output="(css or js)"
debug=(true or false)
filters="(filter list, comma separated)"
asset_url=(smarty variable for asset url)
}>
<link rel="stylesheet" href="<{$asset_url}>">
<{/assets}>
25
© 2014 XOOPS Foundation www.xoops.org
ASSETS TAG ARGUMENT
● assets - comma separated list of assets
to process.
● output - type of output, “css” or “js”
● debug - true to enable debug mode,
default is false
● filters - list of filters to apply, if not
specifed will use default filters for output
type
● asset_url - smarty variable to assign
asset path, defaults to “asset_url”
26
© 2014 XOOPS Foundation www.xoops.org
BEHIND THE SCENES
● XoopsCoreAssets.php handles
communication with the Assetic
library
● Xoops object establishes a single
instance of Assets class, and
XoopsTheme references it
● Configuration of Assets class is in
xoops_path/configs/system_assets_p
refs.yml, but it normally should not
need to be changed
27
© 2014 XOOPS Foundation www.xoops.org
copyFileAssets()
To handle fonts and images in some special
circumstances, a file copy function is
provided.
XoopsCoreAssets::copyFileAssets()
This method copies files to the asset
directory. Copying is normally only needed
for fonts or images when they are
referenced by a relative URL in a stylesheet,
or are located outside of the web root, as
might be the case of a file asset located in a
vendor package.
28
© 2014 XOOPS Foundation www.xoops.org
TURNING ON DEBUG
● Easiest way is to include ASSET_DEBUG=1
in the URL, i.e. index.php?
ASSET_DEBUG=1
● Add this call to your code:
Xoops::getInstance()->assets()->setDebug(true);
● Add debug=true to a Smarty assets tag
● Any of these will turn off any filters
prefixed with a question mark (by default
cssmin and jsmin)
29
© 2014 XOOPS Foundation www.xoops.org
The best source of asset management
examples is in XOOPS 2.6.0 itself.
EXAMPLES
30
© 2014 XOOPS Foundation www.xoops.org
If you have any suggestions,
comments or questions, please make
them known.
You can contact the author here :
richard@geekwright.com
IDEAS ? QUESTIONS ?
www.xoops.org

Weitere ähnliche Inhalte

Was ist angesagt?

Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
Harit Kothari
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
lucenerevolution
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
Fabrizio Giudici
 

Was ist angesagt? (20)

RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi Mensah
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
 
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Wordpress Workflow
Wordpress Workflow Wordpress Workflow
Wordpress Workflow
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Apache servicemix1
Apache servicemix1Apache servicemix1
Apache servicemix1
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 Developer
 

Ähnlich wie XOOPS 2.6.0 Assets Management using Assetic

Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
Erik Hatcher
 

Ähnlich wie XOOPS 2.6.0 Assets Management using Assetic (20)

What's New in Nuxeo Platform 7.3
What's New in Nuxeo Platform 7.3 What's New in Nuxeo Platform 7.3
What's New in Nuxeo Platform 7.3
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
 
Apache Kite
Apache KiteApache Kite
Apache Kite
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
Alfresco overview EDM
Alfresco overview EDMAlfresco overview EDM
Alfresco overview EDM
 
AEM Asset and Tag API
AEM Asset and Tag APIAEM Asset and Tag API
AEM Asset and Tag API
 
Silverlight Development & The Model-View-ViewModel Pattern
Silverlight Development & The Model-View-ViewModel PatternSilverlight Development & The Model-View-ViewModel Pattern
Silverlight Development & The Model-View-ViewModel Pattern
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
CMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg BrownCMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg Brown
 
Asp folders and web configurations
Asp folders and web configurationsAsp folders and web configurations
Asp folders and web configurations
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Decoupling Drupal 8.x: Drupal’s Web Services Today and Tomorrow
Decoupling Drupal 8.x: Drupal’s Web Services Today and TomorrowDecoupling Drupal 8.x: Drupal’s Web Services Today and Tomorrow
Decoupling Drupal 8.x: Drupal’s Web Services Today and Tomorrow
 
Bootstrap4XPages webinar
Bootstrap4XPages webinarBootstrap4XPages webinar
Bootstrap4XPages webinar
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
 
Introduction to Azure Resource Manager, Global Azure Bootcamp 2016.04
Introduction to Azure Resource Manager, Global Azure Bootcamp 2016.04Introduction to Azure Resource Manager, Global Azure Bootcamp 2016.04
Introduction to Azure Resource Manager, Global Azure Bootcamp 2016.04
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Developing Branding Solutions for 2013
Developing Branding Solutions for 2013Developing Branding Solutions for 2013
Developing Branding Solutions for 2013
 
Developing Branding Solutions for 2013
Developing Branding Solutions for 2013Developing Branding Solutions for 2013
Developing Branding Solutions for 2013
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web Services
 

Kürzlich hochgeladen

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 

XOOPS 2.6.0 Assets Management using Assetic

  • 1. INTRODUCTION TOINTRODUCTION TO ASSET MANAGEMENTASSET MANAGEMENT IN XOOPS CMS ENVIRONMENTIN XOOPS CMS ENVIRONMENT XOOPS 2.6.0XOOPS 2.6.0 Education SeriesEducation Series Richard Griffith XOOPS Core Team Leader April 2014© 2014 XOOPS Foundation www.xoops.org
  • 2. 2 © 2014 XOOPS Foundation www.xoops.org ASSETS Most of the focus in XOOPS asset management is on stylesheet and script assets. Most of the focus in XOOPS asset management is on stylesheet and script assets. A web page consists of a base HTML document and any additional files it may include, such as stylesheets, scripts, images and fonts. We will refer to these additional files as assets. HTML Text Images Media HTML Text Images Media CSS Page layout Text styles CSS Page layout Text styles JS, PHP,etc Scripts Database Interraction JS, PHP,etc Scripts Database Interraction Content FunctionsStyles + +
  • 3. 3 © 2014 XOOPS Foundation www.xoops.org Assets are a very important part of the user experience. For today's rich, highly interactive web applications, the asset performance may be more significant than the backend application and database performance. ASSETS ARE VALUABLE Source: http://www.stevesouders.com/
  • 4. 4 © 2014 XOOPS Foundation www.xoops.org ASSET PERFORMANCE FACTORS Asset size Number of files Latency ● Network speed  Connection set up an tear down  Transfer rate  Currency limits ● Client capacity  Processing power/load  Memory  Cache speed
  • 5. 5 © 2014 XOOPS Foundation www.xoops.org MANAGEMENT STRATEGIES Minimize file sizes Combine files to reduce network connections Serve assets as static files to maximize caching Avoid concurrency bottlenecks ●Assets that include other assets when loaded
  • 6. 6 © 2014 XOOPS Foundation www.xoops.org DEVELOPMENT VS. DEPLOYMENT Develop / Debug ●Easy to read and edit is essential ●Separate files are easier to work with and my come from different sources Deployment Focus ●Eliminate formatting and whitespace ●Combine files to eliminate latency
  • 7. 7 © 2014 XOOPS Foundation www.xoops.org SOLVED WITH ASSET MANAGEMENT Develop / Debug ●Easy to read and edit is essential ●Separate files are easier to work with Asset management solves the development vs. deployment dilemma by using the exact same sources for both needs. Asset management solves the development vs. deployment dilemma by using the exact same sources for both needs. Deployment Focus ●Eliminate formatting and whitespace ●Combine files to eliminate latency
  • 8. 8 © 2014 XOOPS Foundation www.xoops.org THE BASICS Specify a file or set of files as an asset Specify filters to apply to that asset Create a static file from the asset for the browser to load which : ●Contains the content of all the specified files ●Has all the specified filters applied ●Is transferred as a single unit Asset Management allows you to:
  • 9. 9 © 2014 XOOPS Foundation www.xoops.org XOOPS Asset Management is built on Assetic, by Kris Wallsmith. For a deeper understanding of some of the concepts, review the documentation available at: https://github.com/kriswallsmith/assetic THE BASICS - CONTINUED
  • 10. 10 © 2014 XOOPS Foundation www.xoops.org THE BASICS - FILES An asset can be a set of script or stylesheet files, not both An asset is defined by an array of file specifications A file can be specified by a fully qualified filesystem name, or by a path resolvable by the XOOPS path() function A file specification can also be a wildcard pattern
  • 11. 11 © 2014 XOOPS Foundation www.xoops.org XOOPS Asset Management comes configured with a subset of the possible Assetic filters. One major criteria for the selection of these filters is they are all implemented in PHP and require no additional binary packages to be installed on the server. These filters are portable and will be available for use where ever XOOPS is installed. Filters are specified as a string of comma separated filter names. A filter name can be preceded with a question mark (“?”) to turn it off during debugging. THE BASICS - FILTERS
  • 12. 12 © 2014 XOOPS Foundation www.xoops.org THE BASICS–FILTERS-CONTINUED Filter Name Assetic Filter Name Description cssembed PhpCssEmbedFilter embeds image data in your stylesheets cssimport CssImportFilter inlines imported stylesheets cssmin CssMinFilter minifies CSS cssrewrite CssRewriteFilter fixes relative URLs in CSS lessphp LessphpFilter Complile LESS to CSS scssphp ScssphpFilter Compile SCSS to CSS jsmin JSMinFilter minifies Javascript These are the available filters :
  • 13. 13 © 2014 XOOPS Foundation www.xoops.org THE BASICS–FILTERS-CONTINUED If no filters are specified, default filters will be applied. ● Stylesheets – 'cssimport,cssembed,?cssmin' ● Javascript – '?jsmin'
  • 14. 14 © 2014 XOOPS Foundation www.xoops.org ASSETS LOCATION : CORE ● Managed assets are stored in the “assets” directory in the XOOPS web root – stylesheets in css sub-directory – scripts in js sub-directory ● These managed directories can be cleared, and contents will be recreated as needed ● Other subdirectories, such as fonts, are managed differently
  • 15. 15 © 2014 XOOPS Foundation www.xoops.org ASSETS LOCATION : MODULES ● Module's Assets are also placed in an “assets” folder, similar to Core ● In order to take advantage of Assetic, current modules should convert to this folder structure
  • 16. 16 © 2014 XOOPS Foundation www.xoops.org LAZY MANAGEMENT ● Each page load specifies the set of assets it needs ● The lists of files, modification times, and filters to apply are used to build unique asset names ● If the static file with that name does not exist, the asset files are processed and filtered, and the static file is created ● There are no separate formula extraction or preprocessing steps needed
  • 17. 17 © 2014 XOOPS Foundation www.xoops.org EXISTING FUNCTIONS XOOPS has historically provided two methods in the XoopsTheme class to deal with assets: ● addScript($url) ● addStylesheet($url) * Note that these methods expect URLs, not filesystem paths.
  • 18. 18 © 2014 XOOPS Foundation www.xoops.org NEW ASSET FUNCTION The XoopsTheme class has been expanded to better manage assets. The following methods are available: ● addScriptAssets($assets, $filters) ● addStylesheetAssets($assets, $filters) ● addBaseScriptAssets($assets) ● addBaseStylesheetAssets($assets) ● setNamedAsset($name, $assets, $filters)
  • 19. 19 © 2014 XOOPS Foundation www.xoops.org addScriptAssets & addStylesheetAssets ● Accept an array of one or more asset file specifications ● Optionally accept a string of comma separated filter names ● Result in combining and filtering the assets, then adding the URL for the created static asset file to the same lists used by addScript() and addStylesheet()
  • 20. 20 © 2014 XOOPS Foundation www.xoops.org addBaseScriptAssets & addBaseStylesheetAssets ● Accept an array of one or more asset file specifications ● Accumulate asset files in separate lists, similar to addScript() and addStylesheet() ● Assets are processed using default filters and the resulting static file URL is added to the top of respective list in the page headers: <{$xoops_module_header}>
  • 21. 21 © 2014 XOOPS Foundation www.xoops.org BASE ASSETS ● Core uses the base assets for common system wide assets, such as jQuery, jQueryUI, locale and Bootstrap assets ● Themes can add to the base assets using theme_onload.php ● Modules may want to add their common assets to the base asset ● Browser cache use is improved if the same base asset definition is used for many pages
  • 22. 22 © 2014 XOOPS Foundation www.xoops.org setNamedAsset ● Accepts a unique asset name ● Accepts an array of one or more asset file specifications ● Optionally accepts a string of comma separated filter names ● Results in creating an asset reference that can be specified in asset arrays in place of a file specification
  • 23. 23 © 2014 XOOPS Foundation www.xoops.org NAMED ASSETS ● Named assets allow symbolic reference to commonly used assets (i.e. “jquery”) ● Named assets can be given additional filters ● Using setNamedAsset does not create the asset, it just records the name and definition ● To use an asset named “jquery” include an asset name of “@jquery” in an asset list
  • 24. 24 © 2014 XOOPS Foundation www.xoops.org SMARTY ASSETS TAG The Smarty block plugin allows assets to be defined in templates. Full syntax: <{assets assets="(file specifications, comma separated)” output="(css or js)" debug=(true or false) filters="(filter list, comma separated)" asset_url=(smarty variable for asset url) }> <link rel="stylesheet" href="<{$asset_url}>"> <{/assets}>
  • 25. 25 © 2014 XOOPS Foundation www.xoops.org ASSETS TAG ARGUMENT ● assets - comma separated list of assets to process. ● output - type of output, “css” or “js” ● debug - true to enable debug mode, default is false ● filters - list of filters to apply, if not specifed will use default filters for output type ● asset_url - smarty variable to assign asset path, defaults to “asset_url”
  • 26. 26 © 2014 XOOPS Foundation www.xoops.org BEHIND THE SCENES ● XoopsCoreAssets.php handles communication with the Assetic library ● Xoops object establishes a single instance of Assets class, and XoopsTheme references it ● Configuration of Assets class is in xoops_path/configs/system_assets_p refs.yml, but it normally should not need to be changed
  • 27. 27 © 2014 XOOPS Foundation www.xoops.org copyFileAssets() To handle fonts and images in some special circumstances, a file copy function is provided. XoopsCoreAssets::copyFileAssets() This method copies files to the asset directory. Copying is normally only needed for fonts or images when they are referenced by a relative URL in a stylesheet, or are located outside of the web root, as might be the case of a file asset located in a vendor package.
  • 28. 28 © 2014 XOOPS Foundation www.xoops.org TURNING ON DEBUG ● Easiest way is to include ASSET_DEBUG=1 in the URL, i.e. index.php? ASSET_DEBUG=1 ● Add this call to your code: Xoops::getInstance()->assets()->setDebug(true); ● Add debug=true to a Smarty assets tag ● Any of these will turn off any filters prefixed with a question mark (by default cssmin and jsmin)
  • 29. 29 © 2014 XOOPS Foundation www.xoops.org The best source of asset management examples is in XOOPS 2.6.0 itself. EXAMPLES
  • 30. 30 © 2014 XOOPS Foundation www.xoops.org If you have any suggestions, comments or questions, please make them known. You can contact the author here : richard@geekwright.com IDEAS ? QUESTIONS ? www.xoops.org