From f2a7fcf8220ef497c8f39f0c9ec3175757f53128 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 9 Aug 2012 19:09:55 -0700 Subject: [PATCH] more theme modularisation and css/js management --- include/plugin.php | 7 +- index.php | 40 ++---- view/php/theme_init.php | 26 ++++ .../quattro/{ => tpl}/birthdays_reminder.tpl | 0 view/theme/quattro/{ => tpl}/comment_item.tpl | 0 .../quattro/{ => tpl}/contact_template.tpl | 0 view/theme/quattro/{ => tpl}/conversation.tpl | 0 .../quattro/{ => tpl}/events_reminder.tpl | 0 .../theme/quattro/{ => tpl}/fileas_widget.tpl | 0 .../{ => tpl}/generic_links_widget.tpl | 0 view/theme/quattro/{ => tpl}/group_side.tpl | 0 view/theme/quattro/{ => tpl}/jot.tpl | 0 view/theme/quattro/{ => tpl}/mail_conv.tpl | 0 view/theme/quattro/{ => tpl}/mail_display.tpl | 0 view/theme/quattro/{ => tpl}/mail_list.tpl | 0 view/theme/quattro/{ => tpl}/message_side.tpl | 0 view/theme/quattro/{ => tpl}/msg-header.tpl | 0 view/theme/quattro/{ => tpl}/nav.tpl | 0 view/theme/quattro/{ => tpl}/nets.tpl | 0 view/theme/quattro/{ => tpl}/photo_view.tpl | 0 .../theme/quattro/{ => tpl}/profile_vcard.tpl | 0 .../{ => tpl}/saved_searches_aside.tpl | 0 view/theme/quattro/{ => tpl}/search_item.tpl | 0 .../quattro/{ => tpl}/theme_settings.tpl | 0 .../quattro/tpl/threaded_conversation.tpl | 35 +++++ view/theme/quattro/{ => tpl}/wall_item.tpl | 0 .../theme/quattro/{ => tpl}/wall_item_tag.tpl | 0 view/theme/quattro/tpl/wall_thread.tpl | 127 +++++++++++++++++ .../theme/quattro/{ => tpl}/wallwall_item.tpl | 0 view/theme/quattro/tpl/wallwall_thread.tpl | 134 ++++++++++++++++++ view/tpl/head.tpl | 38 +---- view/tpl/threaded_conversation.tpl | 13 ++ view/tpl/wall_thread.tpl | 100 +++++++++++++ view/tpl/wallwall_thread.tpl | 105 ++++++++++++++ 34 files changed, 562 insertions(+), 63 deletions(-) create mode 100644 view/php/theme_init.php rename view/theme/quattro/{ => tpl}/birthdays_reminder.tpl (100%) rename view/theme/quattro/{ => tpl}/comment_item.tpl (100%) rename view/theme/quattro/{ => tpl}/contact_template.tpl (100%) rename view/theme/quattro/{ => tpl}/conversation.tpl (100%) rename view/theme/quattro/{ => tpl}/events_reminder.tpl (100%) rename view/theme/quattro/{ => tpl}/fileas_widget.tpl (100%) rename view/theme/quattro/{ => tpl}/generic_links_widget.tpl (100%) rename view/theme/quattro/{ => tpl}/group_side.tpl (100%) rename view/theme/quattro/{ => tpl}/jot.tpl (100%) rename view/theme/quattro/{ => tpl}/mail_conv.tpl (100%) rename view/theme/quattro/{ => tpl}/mail_display.tpl (100%) rename view/theme/quattro/{ => tpl}/mail_list.tpl (100%) rename view/theme/quattro/{ => tpl}/message_side.tpl (100%) rename view/theme/quattro/{ => tpl}/msg-header.tpl (100%) rename view/theme/quattro/{ => tpl}/nav.tpl (100%) rename view/theme/quattro/{ => tpl}/nets.tpl (100%) rename view/theme/quattro/{ => tpl}/photo_view.tpl (100%) rename view/theme/quattro/{ => tpl}/profile_vcard.tpl (100%) rename view/theme/quattro/{ => tpl}/saved_searches_aside.tpl (100%) rename view/theme/quattro/{ => tpl}/search_item.tpl (100%) rename view/theme/quattro/{ => tpl}/theme_settings.tpl (100%) create mode 100644 view/theme/quattro/tpl/threaded_conversation.tpl rename view/theme/quattro/{ => tpl}/wall_item.tpl (100%) rename view/theme/quattro/{ => tpl}/wall_item_tag.tpl (100%) create mode 100644 view/theme/quattro/tpl/wall_thread.tpl rename view/theme/quattro/{ => tpl}/wallwall_item.tpl (100%) create mode 100644 view/theme/quattro/tpl/wallwall_thread.tpl create mode 100644 view/tpl/threaded_conversation.tpl create mode 100644 view/tpl/wall_thread.tpl create mode 100644 view/tpl/wallwall_thread.tpl diff --git a/include/plugin.php b/include/plugin.php index a6780d701..c9490eb8a 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -406,8 +406,7 @@ function upgrade_bool_message($bbcode = false) { function head_add_css($src,$media = 'screen') { - get_app()->css_sources[] = array($src,$type); - + get_app()->css_sources[] = array($src,$media); } function head_get_css() { @@ -430,7 +429,7 @@ function format_css_if_exists($source) { elseif(file_exists('view/css/' . $source[0])) $path = 'view/css/' . $source[0]; if($path) - return ''; + return '' . "\r\n"; } @@ -459,7 +458,7 @@ function format_js_if_exists($source) { elseif(file_exists('view/js/' . $source)) $path = 'view/js/' . $source[0]; if($path) - return '' . "\r\n" ; } diff --git a/index.php b/index.php index 02d853d06..4de315520 100644 --- a/index.php +++ b/index.php @@ -336,30 +336,18 @@ if($a->module != 'install') { * Build the page - now that we have all the components */ +if(file_exists('view/theme/' . current_theme() . '/php/theme_init.php')) + require_once('view/theme/' . current_theme() . '/php/theme_init.php'); +elseif(file_exists('view/theme/' . $a->theme_info['extends'] . '/php/theme_init.php')) + require_once('view/theme/' . $a->theme_info['extends'] . '/php/theme_init.php'); +else + require_once('view/php/theme_init.php'); -$page_css = 'view/theme/' . current_theme() . '/css/' - . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css'; - -if(! file_exists($page_css)) - $page_css = str_replace('theme/' . current_theme() . '/', '', $page_css); - -$module_css = 'view/theme/' . current_theme() . '/css/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; - - -$module_js = 'view/theme/' . current_theme() . '/js/mod_' . $a->module . '.js'; - -if(! file_exists($module_js)) - $module_js = str_replace('theme/' . current_theme() . '/', '', $module_js); - -if(! file_exists($module_js)) - $module_js = null; +head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css'); +head_add_css('mod_' . $a->module . '.css'); +head_add_css('style.css'); +head_add_js('mod_' . $a->module . '.js'); $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000); @@ -378,11 +366,9 @@ if(! file_exists($module_js)) '$showmore' => t('show more'), '$showfewer' => t('show fewer'), '$update_interval' => $interval, - '$page_css' => $a->get_baseurl() . '/' . $page_css, - '$module_css' => (($module_css) ? $a->get_baseurl() . '/' . $module_css : null), - '$module_js' => (($module_js) ? $a->get_baseurl() . '/' . $module_js : null), - '$stylesheet' => current_theme_url(), - '$theme' => current_theme(), + '$head_css' => head_get_css(), + '$head_js' => head_get_js(), + // localisations for jquery.timeago.js, see https://github.com/rmm5t/jquery-timeago // TRANSLATORS - only translate the conditionals if you require them! diff --git a/view/php/theme_init.php b/view/php/theme_init.php new file mode 100644 index 000000000..7a8f2d7a0 --- /dev/null +++ b/view/php/theme_init.php @@ -0,0 +1,26 @@ + + + {{ if $item.type == tag }} + {{ inc wall_item_tag.tpl }}{{ endinc }} + {{ else }} + {{ inc $item.template }}{{ endinc }} + {{ endif }} + + +{{ endfor }} + +
+ +{{ if $dropping }} + + $dropping + +{{ endif }} + + + +{{ if $mode == display }} + +{{ endif }} + diff --git a/view/theme/quattro/wall_item.tpl b/view/theme/quattro/tpl/wall_item.tpl similarity index 100% rename from view/theme/quattro/wall_item.tpl rename to view/theme/quattro/tpl/wall_item.tpl diff --git a/view/theme/quattro/wall_item_tag.tpl b/view/theme/quattro/tpl/wall_item_tag.tpl similarity index 100% rename from view/theme/quattro/wall_item_tag.tpl rename to view/theme/quattro/tpl/wall_item_tag.tpl diff --git a/view/theme/quattro/tpl/wall_thread.tpl b/view/theme/quattro/tpl/wall_thread.tpl new file mode 100644 index 000000000..4d454f00d --- /dev/null +++ b/view/theme/quattro/tpl/wall_thread.tpl @@ -0,0 +1,127 @@ +{{if $mode == display}} +{{ else }} +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} +{{ endif }} + +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} diff --git a/view/theme/quattro/wallwall_item.tpl b/view/theme/quattro/tpl/wallwall_item.tpl similarity index 100% rename from view/theme/quattro/wallwall_item.tpl rename to view/theme/quattro/tpl/wallwall_item.tpl diff --git a/view/theme/quattro/tpl/wallwall_thread.tpl b/view/theme/quattro/tpl/wallwall_thread.tpl new file mode 100644 index 000000000..cc2f8e362 --- /dev/null +++ b/view/theme/quattro/tpl/wallwall_thread.tpl @@ -0,0 +1,134 @@ +{{if $mode == display}} +{{ else }} +{{if $item.comment_firstcollapsed}} +
+ $item.num_comments $item.hide_text +
+ {{endif}} +{{ endif }} + +{{ if $item.flatten }} +
+ $item.comment +
+{{ endif }} diff --git a/view/tpl/head.tpl b/view/tpl/head.tpl index 7853361d9..08fe8303a 100644 --- a/view/tpl/head.tpl +++ b/view/tpl/head.tpl @@ -2,16 +2,13 @@ - - - - + - -{{ if $module_css }} - -{{ endif }} - +$head_css + +$head_js - - - - - - - - - - - - - - -{{ if $module_js }} - -{{ endif }} - - - -