aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-02-19 16:50:41 -0800
committerzotlabs <mike@macgirvin.com>2017-02-19 16:50:41 -0800
commit573846707ceade4d00a4dfe3184d9f8004a3112b (patch)
tree501d9508c22be518894cb18dfec13416412073cb
parent02e487f30687a1602bd257e2acf2b9954aab6e98 (diff)
downloadvolse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.tar.gz
volse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.tar.bz2
volse-hubzilla-573846707ceade4d00a4dfe3184d9f8004a3112b.zip
fix several places where head_add_(css|js) functions have been used incorrectly. It appears that mistakes were made going back a long time and propagated. Here's the way it should work:
- if there is no preceding / character, we look for the file within all the appropriate theme directories. - otherwise the file should have a preceding /, which means use this path relative to the hubzilla basedir - files beginning with // are considered to be schemeless URLs. Therefore 'foo.css' means find the best theme-able representation of foo.css. '/library/foo.css' means only use the version of foo.css that is in /library.
-rw-r--r--Zotlabs/Module/Wiki.php2
-rw-r--r--Zotlabs/Render/Theme.php4
-rwxr-xr-xboot.php9
-rwxr-xr-xinclude/plugin.php32
-rw-r--r--view/php/theme_init.php58
-rw-r--r--view/theme/redbasic/php/theme_init.php26
6 files changed, 68 insertions, 63 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index d42c26681..d0856f4d6 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -296,7 +296,7 @@ class Wiki extends \Zotlabs\Web\Controller {
));
if($p['mimeType'] != 'text/bbcode')
- head_add_js('library/ace/ace.js'); // Ace Code Editor
+ head_add_js('/library/ace/ace.js'); // Ace Code Editor
return $o;
}
diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php
index 9f9009d72..dadb18051 100644
--- a/Zotlabs/Render/Theme.php
+++ b/Zotlabs/Render/Theme.php
@@ -125,9 +125,9 @@ class Theme {
$opts .= $schema_str;
if(file_exists('view/theme/' . $t . '/php/style.php'))
- return('view/theme/' . $t . '/php/style.pcss' . $opts);
+ return('/view/theme/' . $t . '/php/style.pcss' . $opts);
- return('view/theme/' . $t . '/css/style.css');
+ return('/view/theme/' . $t . '/css/style.css');
}
function debug() {
diff --git a/boot.php b/boot.php
index a435f5ac8..7120632f4 100755
--- a/boot.php
+++ b/boot.php
@@ -2225,7 +2225,7 @@ function construct_page(&$a) {
// Zotlabs\Render\Theme::debug();
if (($p = theme_include($current_theme[0] . '.js')) != '')
- head_add_js($p);
+ head_add_js('/' . $p);
if (($p = theme_include('mod_' . App::$module . '.php')) != '')
require_once($p);
@@ -2237,10 +2237,13 @@ function construct_page(&$a) {
else
head_add_css(((x(App::$page, 'template')) ? App::$page['template'] : 'default' ) . '.css');
- head_add_css('mod_' . App::$module . '.css');
+ if (($p = theme_include('mod_' . App::$module . '.css')) != '')
+ head_add_css('mod_' . App::$module . '.css');
+
head_add_css(Zotlabs\Render\Theme::url($installing));
- head_add_js('mod_' . App::$module . '.js');
+ if (($p = theme_include('mod_' . App::$module . '.js')) != '')
+ head_add_js('mod_' . App::$module . '.js');
App::build_pagehead();
diff --git a/include/plugin.php b/include/plugin.php
index 3a64f67cc..068e482d6 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -598,16 +598,23 @@ function head_get_links() {
function format_css_if_exists($source) {
- $path_prefix = script_path() . '/';
- if (strpos($source[0], '/') !== false) {
- // The source is a URL
- $path = $source[0];
+ // script_path() returns https://yoursite.tld
+
+ $path_prefix = script_path();
+
+ $script = $source[0];
+
+ if(strpos($script, '/') !== false) {
+ // The script is a path relative to the server root
+ $path = $script;
// If the url starts with // then it's an absolute URL
- if($source[0][0] === '/' && $source[0][1] === '/') $path_prefix = '';
+ if(substr($script,0,2) === '//') {
+ $path_prefix = '';
+ }
} else {
// It's a file from the theme
- $path = theme_include($source[0]);
+ $path = '/' . theme_include($script);
}
if($path) {
@@ -697,16 +704,19 @@ function head_get_main_js() {
}
function format_js_if_exists($source) {
- $path_prefix = script_path() . '/';
+ $path_prefix = script_path();
if(strpos($source,'/') !== false) {
- // The source is a URL
+ // The source is a known path on the system
$path = $source;
// If the url starts with // then it's an absolute URL
- if($source[0] === '/' && $source[1] === '/') $path_prefix = '';
- } else {
+ if(substr($source,0,2) === '//') {
+ $path_prefix = '';
+ }
+ }
+ else {
// It's a file from the theme
- $path = theme_include($source);
+ $path = '/' . theme_include($source);
}
if($path) {
$qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;
diff --git a/view/php/theme_init.php b/view/php/theme_init.php
index 85da4d782..869b97473 100644
--- a/view/php/theme_init.php
+++ b/view/php/theme_init.php
@@ -2,51 +2,45 @@
require_once('include/plugin.php');
-head_add_css('library/tiptip/tipTip.css');
-head_add_css('library/jgrowl/jquery.jgrowl.css');
-head_add_css('library/jRange/jquery.range.css');
+head_add_css('/library/tiptip/tipTip.css');
+head_add_css('/library/jgrowl/jquery.jgrowl.css');
+head_add_css('/library/jRange/jquery.range.css');
-head_add_css('view/css/conversation.css');
-head_add_css('view/css/widgets.css');
-head_add_css('view/css/colorbox.css');
-head_add_css('library/justifiedGallery/justifiedGallery.min.css');
-head_add_css('library/Text_Highlighter/sample.css');
+head_add_css('/view/css/conversation.css');
+head_add_css('/view/css/widgets.css');
+head_add_css('/view/css/colorbox.css');
+head_add_css('/library/justifiedGallery/justifiedGallery.min.css');
+head_add_css('/library/Text_Highlighter/sample.css');
head_add_js('jquery.js');
-//head_add_js('jquery.migrate-3.0.0.js');
-head_add_js('library/justifiedGallery/jquery.justifiedGallery.min.js');
-head_add_js('library/sprintf.js/dist/sprintf.min.js');
+head_add_js('/library/justifiedGallery/jquery.justifiedGallery.min.js');
+head_add_js('/library/sprintf.js/dist/sprintf.min.js');
-//head_add_js('jquery-compat.js');
head_add_js('spin.js');
head_add_js('jquery.spin.js');
head_add_js('jquery.textinputs.js');
head_add_js('autocomplete.js');
-head_add_js('library/jquery-textcomplete/jquery.textcomplete.js');
-//head_add_js('library/colorbox/jquery.colorbox.js');
-head_add_js('library/jquery.timeago.js');
-head_add_js('library/readmore.js/readmore.js');
-head_add_js('library/sticky-kit/sticky-kit.js');
-//head_add_js('library/jquery_ac/friendica.complete.js');
-//head_add_js('library/tiptip/jquery.tipTip.minified.js');
-head_add_js('library/jgrowl/jquery.jgrowl_minimized.js');
-//head_add_js('library/tinymce/jscripts/tiny_mce/tiny_mce.js');
-head_add_js('library/cryptojs/components/core-min.js');
-head_add_js('library/cryptojs/rollups/aes.js');
-head_add_js('library/cryptojs/rollups/rabbit.js');
-head_add_js('library/cryptojs/rollups/tripledes.js');
-//head_add_js('library/stylish_select/jquery.stylish-select.js');
+head_add_js('/library/jquery-textcomplete/jquery.textcomplete.js');
+
+head_add_js('/library/jquery.timeago.js');
+head_add_js('/library/readmore.js/readmore.js');
+head_add_js('/library/sticky-kit/sticky-kit.js');
+head_add_js('/library/jgrowl/jquery.jgrowl_minimized.js');
+head_add_js('/library/cryptojs/components/core-min.js');
+head_add_js('/library/cryptojs/rollups/aes.js');
+head_add_js('/library/cryptojs/rollups/rabbit.js');
+head_add_js('/library/cryptojs/rollups/tripledes.js');
+
head_add_js('acl.js');
head_add_js('webtoolkit.base64.js');
head_add_js('main.js');
head_add_js('crypto.js');
-head_add_js('library/jRange/jquery.range.js');
-//head_add_js('docready.js');
-head_add_js('library/colorbox/jquery.colorbox-min.js');
+head_add_js('/library/jRange/jquery.range.js');
+head_add_js('/library/colorbox/jquery.colorbox-min.js');
-head_add_js('library/jquery.AreYouSure/jquery.are-you-sure.js');
-head_add_js('library/tableofcontents/jquery.toc.js');
-head_add_js('library/imagesloaded/imagesloaded.pkgd.min.js');
+head_add_js('/library/jquery.AreYouSure/jquery.are-you-sure.js');
+head_add_js('/library/tableofcontents/jquery.toc.js');
+head_add_js('/library/imagesloaded/imagesloaded.pkgd.min.js');
/**
* Those who require this feature will know what to do with it.
* Those who don't, won't.
diff --git a/view/theme/redbasic/php/theme_init.php b/view/theme/redbasic/php/theme_init.php
index 3179c7078..020bda363 100644
--- a/view/theme/redbasic/php/theme_init.php
+++ b/view/theme/redbasic/php/theme_init.php
@@ -1,19 +1,17 @@
<?php
-head_add_css('library/font_awesome/css/font-awesome.min.css');
-head_add_css('library/bootstrap/css/bootstrap.min.css');
-head_add_css('library/bootstrap-tagsinput/bootstrap-tagsinput.css');
-head_add_css('view/css/bootstrap-red.css');
-head_add_css('library/datetimepicker/jquery.datetimepicker.css');
-//head_add_css('library/colorpicker/css/colorpicker.css');
-head_add_css('library/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css');
+head_add_css('/library/font_awesome/css/font-awesome.min.css');
+head_add_css('/library/bootstrap/css/bootstrap.min.css');
+head_add_css('/library/bootstrap-tagsinput/bootstrap-tagsinput.css');
+head_add_css('/view/css/bootstrap-red.css');
+head_add_css('/library/datetimepicker/jquery.datetimepicker.css');
+head_add_css('/library/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css');
require_once('view/php/theme_init.php');
-head_add_js('library/bootstrap/js/bootstrap.min.js');
-head_add_js('library/bootbox/bootbox.min.js');
-head_add_js('library/bootstrap-tagsinput/bootstrap-tagsinput.js');
-head_add_js('library/datetimepicker/jquery.datetimepicker.js');
-//head_add_js('library/colorpicker/js/colorpicker.js');
-head_add_js('library/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js');
-//head_add_js('library/bootstrap-colorpicker/src/js/docs.js');
+head_add_js('/library/bootstrap/js/bootstrap.min.js');
+head_add_js('/library/bootbox/bootbox.min.js');
+head_add_js('/library/bootstrap-tagsinput/bootstrap-tagsinput.js');
+head_add_js('/library/datetimepicker/jquery.datetimepicker.js');
+head_add_js('/library/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js');
+