breakup css into page layout css, and provide module specific layout css - which should dramatically reduce the size of theme files and reduce load times

This commit is contained in:
friendica 2012-07-21 18:03:22 -07:00
parent f8107be85b
commit c1fe66bec5
4 changed files with 48 additions and 22 deletions

View File

@ -585,22 +585,8 @@ if(! class_exists('App')) {
}
function init_pagehead() {
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
if($interval < 10000)
$interval = 40000;
$this->page['title'] = $this->config['sitename'];
$tpl = file_get_contents('view/head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array(
'$baseurl' => $this->get_baseurl(), // FIXME for z_path!!!!
'$local_user' => local_user(),
'$generator' => FRIENDICA_PLATFORM . ' ' . FRIENDICA_VERSION,
'$delitem' => t('Delete this item?'),
'$comment' => t('Comment'),
'$showmore' => t('show more'),
'$showfewer' => t('show fewer'),
'$update_interval' => $interval
));
$this->page['htmlhead'] = file_get_contents('view/head.tpl');
}
function set_curl_code($code) {

View File

@ -356,9 +356,39 @@ if($a->module != 'install') {
* Build the page - now that we have all the components
*/
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'],
array('$stylesheet' => current_theme_url(),
'$theme' => current_theme()
$page_css = 'view/theme/' . current_theme() . '/'
. ((x($a->page,'layout')) ? $a->page['layout'] : 'layout' ) . '.css';
if(! file_exists($page_css))
$page_css = str_replace('theme/' . current_theme() . '/', '', $page_css);
$module_css = 'view/theme/' . current_theme() . '/mod_' . $a->module . '.css';
if(! file_exists($module_css))
$module_css = str_replace('theme/' . current_theme() . '/', '', $module_css);
if(! file_exists($module_css))
$module_css = null;
$interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000);
if($interval < 10000)
$interval = 40000;
$a->page['title'] = $a->config['sitename'];
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
'$baseurl' => $a->get_baseurl(),
'$local_user' => local_user(),
'$generator' => FRIENDICA_PLATFORM . ' ' . FRIENDICA_VERSION,
'$delitem' => t('Delete this item?'),
'$comment' => t('Comment'),
'$showmore' => t('show more'),
'$showfewer' => t('show fewer'),
'$update_interval' => $interval,
'$page_css' => $a->get_baseurl() . '/' . $page_css,
'$module_css' => $a->get_baseurl() . '/' . $module_css,
'$stylesheet' => current_theme_url(),
'$theme' => current_theme()
));
$page = $a->page;

View File

@ -1,7 +1,12 @@
<?php
if(! function_exists('register_post')) {
function register_post(&$a) {
function zregister_init(&$a) {
$a->page['layout'] = 'full';
}
function zregister_post(&$a) {
global $lang;
@ -155,7 +160,7 @@ function register_post(&$a) {
}
return;
}}
}

View File

@ -1,11 +1,16 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<base href="$baseurl/" />
<meta name="generator" content="$generator" />
<link rel="stylesheet" href="$baseurl/library/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
<link rel="stylesheet" href="$baseurl/library/tiptip/tipTip.css" type="text/css" media="screen" />
<link rel="stylesheet" href="$baseurl/library/jgrowl/jquery.jgrowl.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="$baseurl/library/jslider/bin/jquery.slider.min.css" media="screen" />
<link rel="stylesheet" type="text/css" href="$baseurl/library/jslider/bin/jquery.slider.min.css" />
<link rel="stylesheet" type="text/css" href="$page_css" media="all" />
{{ if $mod_css }}
<link rel="stylesheet" type="text/css" href="$mod_css" media="all" />
{{ endif }}
<link rel="stylesheet" type="text/css" href="$stylesheet" media="all" />
<link rel="shortcut icon" href="$baseurl/images/friendica-32.png" />