Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Miva - CSS & JavaScript Minification
<mvt:if expr="NOT ISNULL g.minify_css_enabled">
<mvt:assign name="l.settings:minify:css:enabled" value="g.minify_css_enabled" />
<mvt:else>
<mvt:assign name="l.settings:minify:css:enabled" value="1" />
</mvt:if>
<mvt:if expr="NOT ISNULL g.minify_css_method">
<mvt:assign name="l.settings:minify:css:method" value="g.minify_css_method" />
<mvt:else>
<mvt:assign name="l.settings:minify:css:method" value="'munee'" />
</mvt:if>
<mvt:comment><!-- CSS Files --></mvt:comment>
<mvt:assign name="l.settings:css:files[1]" value="'/css/normalize.css'" />
<mvt:assign name="l.settings:css:files[2]" value="'/css/base.css'" />
<mvt:assign name="l.settings:css:files[3]" value="'/css/scaffolding.css'" />
<mvt:assign name="l.settings:css:files[4]" value="'/css/typography.css'" />
<mvt:assign name="l.settings:css:files[5]" value="'/css/buttons.css'" />
<mvt:assign name="l.settings:css:files[6]" value="'/css/fonts.css'" />
<mvt:assign name="l.settings:css:files[7]" value="'/css/forms.css'" />
<mvt:assign name="l.settings:css:files[8]" value="'/css/tables.css'" />
<mvt:assign name="l.settings:css:files[9]" value="'/css/colors.css'" />
<mvt:assign name="l.settings:css:files[10]" value="'/css/slider.css'" />
<mvt:assign name="l.settings:css:files[11]" value="'/css/tabs.css'" />
<mvt:assign name="l.settings:css:files[12]" value="'/css/helpers.css'" />
<mvt:assign name="l.settings:css:files[13]" value="'/css/structure.css'" />
<mvt:assign name="l.settings:css:files[14]" value="'/css/pages.css'" />
<mvt:assign name="l.settings:css:files[15]" value="'/css/autocomplete.css'" />
<mvt:assign name="l.settings:css:files[16]" value="'/css/print.css'" />
<mvt:assign name="l.settings:css:files[17]" value="'/vendor/jquery.qtip.custom/jquery.qtip.min.css'" />
<mvt:assign name="l.settings:css:files[18]" value="'/vendor/Easy-Responsive-Tabs-to-Accordion/css/easy-responsive-tabs.css'" />
<mvt:assign name="l.settings:minify:css:critical:file" value="'/css/critical.css'" />
<mvt:if expr="NOT l.settings:minify:css:enabled">
<mvt:foreach iterator="file" array="css:files">
<mvt:assign name="l.settings:file" value="l.settings:file $ '?v=' $ stime(l.settings:file)" />
<link rel="stylesheet" href="//&mvte:global:domain:name;&mvt:file;">
</mvt:foreach>
<mvt:else>
<mvt:comment><!-- In-line Critical CSS --></mvt:comment>
<mvt:assign name="l.settings:minify:css:critical:exists" value="sexists(l.settings:minify:css:critical:file)"/>
<mvt:if expr="l.settings:minify:css:critical:exists">
<mvt:assign name="l.settings:minify:css:critical:length" value="file_read(l.settings:minify:css:critical:file, 'script', l.settings:minify:css:critical:contents)"/>
<style>&mvt:minify:css:critical:contents;</style>
</mvt:if>
<mvt:comment><!-- Minify Method --></mvt:comment>
<mvt:if expr="l.settings:minify:css:method EQ 'munee'">
<mvt:assign name="l.settings:minify:css:url" value="'http://www.thepaperstore.com/munee.php?files=' $ l.settings:css:files $ '&minify=true'" />
<mvt:item name="toolkit" param="vcallurl|l.all_settings:minify:css:output_file:contents|l.all_settings:minify:css:url|GET|" />
<mvt:elseif expr="l.settings:minifiy:css:method EQ 'basic_php'">
<mvt:assign name="l.settings:minify:css:url" value="'http://www.thepaperstore.com/css/css_v2.php?files=' $ l.settings:css:files" />
<mvt:item name="toolkit" param="vcallurl|l.all_settings:minify:css:output_file:contents|l.all_settings:minify:css:url|GET|" />
<mvt:else>
<mvt:comment><!-- Concatinate Styles --></mvt:comment>
<mvt:foreach iterator="file" array="css:files">
<mvt:assign name="l.settings:this_file:length" value="file_read(l.settings:file, 'script', l.settings:this_file:contents)"/>
<mvt:assign name="l.settings:minify:css:output_file:contents" value="l.settings:minify:css:output_file:contents $ g.newline $ l.settings:this_file:contents" />
</mvt:foreach>
</mvt:if>
<mvt:comment><!-- Minified Output File Variables --></mvt:comment>
<mvt:assign name="l.settings:minify:css:output_file:directory" value="'/css/'"/>
<mvt:assign name="l.settings:minify:css:output_file:name" value="'miva-styles.min.css'"/>
<mvt:assign name="l.settings:minify:css:output_file:path" value="l.settings:minify:css:output_file:directory $ l.settings:minify:css:output_file:name"/>
<mvt:comment><!-- Determine time of last modified file --></mvt:comment>
<mvt:assign name="l.settings:minify:css:most_recent_stime" value="0" />
<mvt:foreach iterator="file" array="css:files">
<mvt:comment>
<!--
Miva creates new files and sets their File Modified time in GMT.
Therefore, if your FTP program sets the File Modified time in your local time,
then you need to update this accordingly
-->
</mvt:comment>
<mvt:assign name="l.settings:minify:timezone_offset" value="60 * 60 * 8" />
<mvt:assign name="l.settings:minify:css:current_stime" value="stime(l.settings:file) + l.settings:minify:timezone_offset" />
<mvt:assign name="l.settings:file" value="l.settings:file $ '?v=' $ l.settings:minify:css:current_stime" />
<mvt:if expr="l.settings:minify:css:current_stime GT l.settings:minify:css:most_recent_stime">
<mvt:assign name="l.settings:minify:css:most_recent_stime" value="l.settings:minify:css:current_stime" />
</mvt:if>
</mvt:foreach>
<mvt:assign name="l.settings:minify:css:output_file:stime" value="stime(l.settings:minify:css:output_file:path)" />
<mvt:comment><!-- Minified Output File CRUD --></mvt:comment>
<mvt:if expr="l.settings:minify:css:most_recent_stime GT l.settings:minify:css:output_file:stime">
<mvt:assign name="l.settings:minify:css:output_file:stime" value="l.settings:minify:css:most_recent_stime" />
<mvt:assign name="l.settings:minify:css:output_file:exists" value="sexists(l.settings:minify:css:output_file:path)"/>
<mvt:if expr="l.settings:minify:css:output_file:exists EQ 1">
<mvt:assign name="l.settings:minify:css:output_file:deleted" value="sdelete(l.settings:minify:css:output_file:path)"/>
<mvt:if expr="l.settings:minify:css:output_file:deleted EQ 1">
<mvt:assign name="l.settings:minify:css:file_created" value="file_create(l.settings:minify:css:output_file:path, 'script', l.settings:minify:css:output_file:contents)"/>
</mvt:if>
<mvt:else>
<mvt:assign name="l.settings:minify:css:file_created" value="file_create(l.settings:minify:css:output_file:path, 'script', l.settings:minify:css:output_file:contents)"/>
</mvt:if>
</mvt:if>
<link rel="stylesheet" href="//&mvte:global:domain:name;&mvt:minify:css:output_file:path;?v=&mvt:minify:css:output_file:stime;">
</mvt:if>
<mvt:assign name="g.newline" value="asciichar(10)"/>
<mvt:if expr="NOT ISNULL g.minify_js_enabled">
<mvt:assign name="l.settings:minify:js:enabled" value="g.minify_js_enabled" />
<mvt:else>
<mvt:assign name="l.settings:minify:js:enabled" value="1" />
</mvt:if>
<mvt:if expr="NOT ISNULL g.minify_js_method">
<mvt:assign name="l.settings:minify:js:method" value="g.minify_js_method" />
<mvt:else>
<mvt:assign name="l.settings:minify:js:method" value="'munee'" />
</mvt:if>
<mvt:comment>
<!--
<script>
var miva.data = {
minibasket: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(l.all_settings:global_minibasket)" />,
customer: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(g.customer)" />
};
</script>
-->
</mvt:comment>
<mvt:comment><!-- JavaScript Files --></mvt:comment>
<mvt:assign name="l.settings:js:files[1]" value="'/js/modernizr.js'" />
<mvt:assign name="l.settings:js:files[2]" value="'/js/plugins.js'" />
<mvt:assign name="l.settings:js:files[3]" value="'/js/mvscreen.js'" />
<mvt:if expr="NOT l.settings:minify:js:enabled">
<mvt:foreach iterator="file" array="js:files">
<mvt:assign name="l.settings:file" value="l.settings:file $ '?v=' $ stime(l.settings:file)" />
<script src="//&mvte:global:domain:name;&mvt:file;"></script>
</mvt:foreach>
<mvt:else>
<mvt:comment><!-- Minify Method --></mvt:comment>
<mvt:comment><!-- Concatinate Scripts --></mvt:comment>
<mvt:foreach iterator="file" array="js:files">
<mvt:assign name="l.settings:this_file:length" value="file_read(l.settings:file, 'script', l.settings:this_file:contents)"/>
<mvt:assign name="l.settings:minify:js:output_file:contents" value="l.settings:minify:js:output_file:contents $ g.newline $ ';' $ l.settings:this_file:contents" />
</mvt:foreach>
<mvt:comment><!-- Minified Output File Variables --></mvt:comment>
<mvt:assign name="l.settings:minify:js:output_file:directory" value="'/js/'"/>
<mvt:assign name="l.settings:minify:js:output_file:name" value="'miva-scripts.min.js'"/>
<mvt:assign name="l.settings:minify:js:output_file:path" value="l.settings:minify:js:output_file:directory $ l.settings:minify:js:output_file:name"/>
<mvt:comment><!-- Determine time of last modified file --></mvt:comment>
<mvt:assign name="l.settings:minify:js:most_recent_stime" value="0" />
<mvt:foreach iterator="file" array="js:files">
<mvt:comment>
<!--
Miva creates new files and sets their File Modified time in GMT.
Therefore, if your FTP program sets the File Modified time in your local time,
then you need to update this accordingly
-->
</mvt:comment>
<mvt:assign name="l.settings:minify:timezone_offset" value="60 * 60 * 8" />
<mvt:assign name="l.settings:minify:js:current_stime" value="stime(l.settings:file) + l.settings:minify:timezone_offset" />
<mvt:assign name="l.settings:file" value="l.settings:file $ '?v=' $ l.settings:minify:js:current_stime" />
<mvt:if expr="l.settings:minify:js:current_stime GT l.settings:minify:js:most_recent_stime">
<mvt:assign name="l.settings:minify:js:most_recent_stime" value="l.settings:minify:js:current_stime" />
</mvt:if>
</mvt:foreach>
<mvt:assign name="l.settings:minify:js:output_file:stime" value="stime(l.settings:minify:js:output_file:path)" />
<mvt:comment><!-- Minified Output File CRUD --></mvt:comment>
<mvt:if expr="l.settings:minify:js:most_recent_stime GT l.settings:minify:js:output_file:stime">
<mvt:assign name="l.settings:minify:js:output_file:stime" value="l.settings:minify:js:most_recent_stime" />
<mvt:assign name="l.settings:minify:js:output_file:exists" value="sexists(l.settings:minify:js:output_file:path)"/>
<mvt:if expr="l.settings:minify:js:output_file:exists EQ 1">
<mvt:assign name="l.settings:minify:js:output_file:deleted" value="sdelete(l.settings:minify:js:output_file:path)"/>
<mvt:if expr="l.settings:minify:js:output_file:deleted EQ 1">
<mvt:assign name="l.settings:minify:js:file_created" value="file_create(l.settings:minify:js:output_file:path, 'script', l.settings:minify:js:output_file:contents)"/>
</mvt:if>
<mvt:else>
<mvt:assign name="l.settings:minify:js:file_created" value="file_create(l.settings:minify:js:output_file:path, 'script', l.settings:minify:js:output_file:contents)"/>
</mvt:if>
</mvt:if>
<script src="//&mvte:global:domain:name;&mvt:minify:js:output_file:path;?v=&mvt:minify:js:output_file:stime;"></script>
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.