Posted on: 06/24/12 09:18am
By: suprsidr
I'm liking the ability to decide which js files and libs are loaded in layout/themes/my theme/functions.php:
Text Formatted Code
/**
* Return an array of JS libraries to be loaded
*/
function theme_js_libs_foley()
{
return array(
);
}
/**
* Return an array of JS files to be loaded
*/
function theme_js_files_foley()
{
global $_CONF;
return array(
);
}
BUT <- you knew that was coming
Maybe we could return an array of arrays for header and footer ie.
Text Formatted Code
/**
* Return an array of JS libraries to be loaded
*/
function theme_js_libs_foley()
{
return array(
'header' => array('jquery'),
'footer' => array('jquerui')
);
}
/**
* Return an array of JS files to be loaded
*/
function theme_js_files_foley()
{
global $_CONF;
return array(
'header' => array('my_theme/js/ie-fix.js', 'my_theme/js/modernizr.js'),
'footer' => array('my_theme/js/jflickrfeed.js', 'my_theme/js/prettify.js')
);
}
I know in the past I've preached all js in the footer for fast page loads, but in a dynamic content system like a blog/CMS it's almost impossible to keep out inline js. Easy to do in a static html pages, but not dynamic pages.
So now I'm always loading jquery and modernizr in the head and all others in the footer.
BUT with geeklog automatically including jquery in the footer for admin pages and the like, it overwrites the already included jquery and bombs any previously defined functionality.
Theme developers need fine control over js and css inclusion, and if geeklog needs a library like jquery for some of its functionality it needs to test for it first before overwriting a previously included version:
Text Formatted Code
<script>!window.jQuery && document.write(unescape('%3Cscript src="{site_url}/javascripts/jquery.min.js"%3E%3C/script%3E'))</script>
And theme developers need to be able to determine when and where to include their resources.
-s
Re: GL 2.0.x theme development
Posted on: 06/24/12 04:52pm
By: Laugh
I think I see where you are going some what with your request and I have seen a few incidences where jquery may be needed in the head instead of the footer. Geeklog does keep track of when jquery and jquery ui is needed and plugins and themes can tell the scripts class when they wanted it to load but just not if it is in the header. For other javascript files it is up to the theme/plugin to tell it to load in the header or footer and it is left up to the theme/plugin to keep track if it has been loaded already or not. I guess if a plugins/themes share javascript libraries this will create difficulties (the same with css files).
We should probably get a detailed feature request going with your ideas including examples. We should also get Dengen involved since he works a lot more on the theme stuff than I do (and I haven't done much dynamic stuff either). Dengen developed the Deniem theme included with Geeklog 2.0.0.
In your other message you mentioned you are basing your new theme on the Geeklog's 2.0.0 professional theme. Currently only Deniem and Modern Curve themes support the new theme features. If $_CONF['supported_version_theme'] is not set to the appropriate version by the themes function.php file then an older theme version is assumed and COM_createHTMLDocument will just call COM_siteHeader and COM_siteFooter directly and return the results.
Tom
Re: GL 2.0.x theme development
Posted on: 06/24/12 05:19pm
By: suprsidr
We should probably get a detailed feature request going
done http://project.geeklog.net/tracking/view.php?id=1459
If $_CONF['supported_version_theme'] is not set
Text Formatted Code
$_CONF['supported_version_theme'] = '2.0.0';
did the trick on my other question, thanks.
-s
Re: GL 2.0.x theme development
Posted on: 06/25/12 09:53am
By: Laugh
Okay so we want the ability to specify if jquery and jquery ui is loaded in the header (currently it can only be loaded in the footer).
What rules should we follow?
- jquery and then jquery ui will always be specified first (either in the header or footer) followed by javascript files
- I guess if jquery is loaded in the header then jquery ui can be loaded in the header or footer
- If jquery is specified to be loaded in the footer by a plugin/theme and then something else specifies it in the header it will default to the header
- If jquery ui is specified to load in the header while jquery is loaded in the footer then move jquery to the header
I don't really see the need for the function theme_js_libs_foley(). The plugin/theme can tell the scripts class to load what it wants, if the class gets multiple requests for the same thing it only specifies the library once.
Also do we want/need function theme_js_files_foley() and function theme_css_files_foley() or should the theme/plugin keep track of what they loaded or not already? Also when these functions are called not all of the javascript files and css files maybe in the list yet since other plugins, blocks, etc.. could yet still add to the lists.
Are we missing anything else?
Thoughts
Tom
Re: GL 2.0.x theme development
Posted on: 06/25/12 10:27am
By: suprsidr
I don't really see the need for the function theme_js_libs_theme_name()
I think it is still relevant, for adding entire libraries and like my example above, header=> or footer=>
I think that once jquery or any file is specified in the header, it should cancel out any call in the footer.
Basically compile a list of js for the header and one for the footer -> compare and create a unique array for header -> array diff for footer.
Also do we want/need function theme_js_files_foley() and function theme_css_files_foley()
As a theme/plugin developer we should use these as we need, if I add the css/js directly to my templates, or do I utilize the scripts class or both.
CSS is another issue - if not included in the correct order one can overwrite another.
Case would be if my theme had its own jqueryui theme and geeklog included it's default jqueryui theme after it would overwrite the theme's.
I have already been struggling w/ these issues.
In my new theme, I have emptied the site's /javascript/jquery.min.js since there is no way of stopping geeklog from including it in the footer on contribute/admin pages - so an empty file is harmless.
-s
Re: GL 2.0.x theme development
Posted on: 06/25/12 11:57am
By: Laugh
Basically compile a list of js for the header and one for the footer -> compare and create a unique array for header -> array diff for footer.
Okay I see where you are going.
CSS is another issue - if not included in the correct order one can overwrite another.
Case would be if my theme had its own jqueryui theme and geeklog included it's default jqueryui theme after it would overwrite the theme's.
Hmm... I see the problem. Along with including function theme_css_files_foley I guess when you add a css file we should allow for the option to include a position for it.
Re: GL 2.0.x theme development
Posted on: 06/26/12 01:33pm
By: dengen
Quote by: suprsidr
And theme developers need to be able to determine when and where to include their resources.
I agree with suprsidr.
Therefore, I think we need to improve the scripts class.
However, I do not know why we should define the following functions.
function theme_config_foley()
function theme_css_foley()
function theme_js_libs_foley()
function theme_init_foley()
dengen
Re: GL 2.0.x theme development
Posted on: 06/26/12 01:51pm
By: suprsidr
However, I do not know why we should define the following functions.
function theme_config_foley()
function theme_css_foley()
function theme_js_libs_foley()
function theme_init_foley()
I'm not hating having separate places in layout/foley/functions.php to organize resources and settings its actually kind of handy.
Plus the latter 3 functions give the scripts class a hook.
-s
Re: GL 2.0.x theme development
Posted on: 06/26/12 11:26pm
By: dengen
My idea is as follows.
Text Formatted Code
$_SCRIPTS->registJavaScriptLibrary(
array(
array(
'library' => 'jquery',
'location' => 'header',
'priority' => '1000'
),
array(
'library' => 'jqueryui',
'location' => 'footer',
'priority' => '1000'
)
)
);
$_SCRIPTS->registJavaScriptFile(
array(
array(
'file' => '/layout/' . $_CONF['theme'] . '/js/ie-fix.js',
'location' => 'header',
'priority' => '100'
),
array(
'file' => '/layout/' . $_CONF['theme'] . '/js/modernizr.js',
'location' => 'header',
'priority' => '100'
),
array(
'file' => '/layout/' . $_CONF['theme'] . '/js/jflickrfeed.js',
'location' => 'footer',
'priority' => '100'
),
array(
'file' => '/layout/' . $_CONF['theme'] . '/js/prettify.js',
'location' => 'footer',
'priority' => '100'
)
)
);
dengen
Re: GL 2.0.x theme development
Posted on: 06/27/12 12:25am
By: suprsidr
That is fine.
Same type of inclusion for css?
Also where do these calls to the $_SCRIPTS class get executed?
This is why function theme_js_libs_theme_name came about.
Themes and plugins should have the same access to the $_SCRIPTS class.
BUT the issue before was that we needed these defined before calls to siteHeader/siteFooter so if we want this to be dynamic the site needs to be built body first ie.
Body -> Header -> Footer
or does that screw up autotags?
-s
Re: GL 2.0.x theme development
Posted on: 06/27/12 07:48am
By: dengen
Same type of inclusion for css?
Maybe it is as follows.
Text Formatted Code
$_SCRIPTS->registCssFile(
array(
array(
'file' => '/layout/' . $_CONF['theme'] . '/style.css',
'attributes' => array('media' => 'all'),
'priority' => '1000'
),
array(
'file' => '/layout/' . $_CONF['theme'] . '/print.css',
'attributes' => array('media' => 'print'),
'priority' => '1'
),
)
);
Also where do these calls to the $_SCRIPTS class get executed?
This is why function theme_js_libs_theme_name came about.
These methods are called in the layout/theme/functions.php.
Also we're possible to use function theme_js_libs_theme_name().
Themes and plugins should have the same access to the $_SCRIPTS class.
$_SCRIPTS is an instance of the scripts class.
And $_SCRIPTS is created in the lib-common.php.
Themes and plugins have the same access to $_SCRIPTS.
BUT the issue before was that we needed these defined before calls to siteHeader/siteFooter so if we want this to be dynamic the site needs to be built body first ie.
Body -> Header -> Footer
or does that screw up autotags?
Sorry. I could not understand your explanation.
In the plugin code, I think if you call methods of $_SCRIPTS before calling the function COM_createHTMLDocument(), there is no problem.
dengen
Re: GL 2.0.x theme development
Posted on: 06/27/12 09:18am
By: Laugh
BUT the issue before was that we needed these defined before calls to siteHeader/siteFooter so if we want this to be dynamic the site needs to be built body first ie.
Body -> Header -> Footer
or does that screw up autotags?
With COM_createHTMLDocument the body is created first but the problem is autotags and blocks. Autotags can be included in template files and Blocks can be generated near the end of the process. Both Autotags and Blocks can add to the scripts class (javascript/css) if they need to.
Re: GL 2.0.x theme development
Posted on: 06/28/12 10:31am
By: dengen
Quote by: LaughWith COM_createHTMLDocument the body is created first but the problem is autotags and blocks. Autotags can be included in template files and Blocks can be generated near the end of the process. Both Autotags and Blocks can add to the scripts class (javascript/css) if they need to.
Thank you for your commentary. I understand this problem.
For Blocks, I think we can resolve by modifying the function COM_createHTMLDocument().
But for Autotags that are included in templates, I think we are hard to resolve.
dengen
Re: GL 2.0.x theme development
Posted on: 06/28/12 10:58pm
By: suprsidr
So here I am trying to over-ride the outdated fckeditor w/ ckeditor from within my new theme.
Even though I have total control of my theme, I cannot abolish that old turd.
Can we not upgrade 2.0 w/ ckeditor? it is far easier to use and configure.
-s
Re: GL 2.0.x theme development
Posted on: 06/29/12 09:30am
By: Laugh
I would like to see something new but I have never really looked much at the editors before.
We have discussed this about 2 years ago on the mailing list and I believe there was a licensing issue (something with the file browser), I am not sure if that is a problem now though.
I believe Ben released a plugin that allowed the integration of the CKEditor and Mystrak-kk did some work with TinyMCE (from http://mystral-kk.net/filemgmt/visit.php?lid=35)
Why don't you bring up this issue in the mailing list? I don't have time to tackle something like this now but maybe someone else will or offer a patch.
Tom
Re: GL 2.0.x theme development
Posted on: 06/29/12 09:42am
By: suprsidr
That was not really my point.
1n 1.8.x and before, the inclusion of the fckeditor.js and the call to initialize was in the adv editor templates.
And replacing those w/ whichever editor I wanted was easy.
But now it appears the scripts class is including everything and no way of stopping it.
If I turn off adv editor in config, the adv editor templates are no longer called.
So this would likely render Ben's plugin useless.
It seems we are losing the ability to customize and control geeklog.
-s
Re: GL 2.0.x theme development
Posted on: 06/29/12 09:46am
By: suprsidr
this is how easy ckeditor is:
Text Formatted Code
<script type="text/javascript" src="{layout_url}/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
CKEDITOR.replace( 'introtext');
CKEDITOR.replace( 'bodytext');
</script>
-s
Re: GL 2.0.x theme development
Posted on: 06/29/12 11:36am
By: Laugh
But now it appears the scripts class is including everything and no way of stopping it.
If I turn off adv editor in config, the adv editor templates are no longer called.
Sounds like we need further modification of the scripts class then.
I am thinking of a config option accessible to the plugins and theme that disables the loading of the fckeditor javascript file. Would that work? This would disable it for the entire site.
Tom
Re: GL 2.0.x theme development
Posted on: 06/29/12 11:47am
By: Laugh
Around line 88 remove the fckeditor from the scripts class and then add to lib-common.php around line 460
Text Formatted Code
// Check to see if advanced editor is needed
if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
if (!isset($_CONF['fckeditor_enabled'])) {
$_CONF['fckeditor_enabled'] = true;
}
if ($_CONF['fckeditor_enabled'] == true) {
$_SCRIPTS->setJavaScriptFile('fckeditor','/fckeditor/fckeditor.js');
}
}
I haven't tested it but it should work. If you like the solution I will add it to Geeklog 2.0.0
Tom
Re: GL 2.0.x theme development
Posted on: 06/29/12 11:49am
By: suprsidr
That would partially work
There are also storyeditor_fckeditor.js, submitcomment_fckeditor.js....
and the problem here is inconsistency, some of these are called by the scripts class and some in templates.
I don't think we need a separate file for each editor.
using jQuery we can just test for the existence of each editor field.
I'm actually in the middle of rewriting these editor files for ckeditor - I'm going to combine them into a common file.
If we could set the editor file url in config then I'd just swap mysite.com/fckeditor/fckeditor.js with mine in theme/functions.php ie.
$_CONF['adv_editor_path'] = /layout/foley/js/ckeditor/ckeditor.js;
$_CONF['adv_editor_js'] = /layout/foley/js/adv-editor.js;
or can overwrite the forced one in scripts in theme/functions.php
$_SCRIPTS->setJavaScriptFile('fckeditor','/layout/foley/js/ckeditor/ckeditor.js'
;
$_SCRIPTS->setJavaScriptFile('adv-editor','/layout/foley/js/adv-editor.js'
;
-s
Re: GL 2.0.x theme development
Posted on: 06/29/12 11:56am
By: Laugh
Yeah I just tested it and saw the problems.
I like your overwrite idea...
Re: GL 2.0.x theme development
Posted on: 06/29/12 02:18pm
By: Laugh
If we could set the editor file url in config then I'd just swap mysite.com/fckeditor/fckeditor.js with mine in theme/functions.php ie.
$_CONF['adv_editor_path'] = /layout/foley/js/ckeditor/ckeditor.js;
$_CONF['adv_editor_js'] = /layout/foley/js/adv-editor.js;
Looking over things I wonder if this is the easier way to go since with the other way you are never sure when things get set (ie contribute form, story, comment, staticpage). Setting the paths at the begining would solve this problem.
Here is for the most part the following javascript that gets set when the advance editor is used:
Text Formatted Code
// Add JavaScript
$_SCRIPTS->setJavaScriptFile('fckeditor','/fckeditor/fckeditor.js');
$js = 'geeklogEditorBasePath = "' . $_CONF['site_url'] . '/fckeditor/";';
// Hide the Advanced Editor as Javascript is required. If JS is enabled then the JS below will un-hide it
$js .= 'document.getElementById("advanced_editor").style.display="";';
$_SCRIPTS->setJavaScript($js, true);
$_SCRIPTS->setJavaScriptFile('submitstory_fckeditor', '/javascript/submitstory_fckeditor.js');
The story editor also sets this which is just used for archive along with showhideEditorDiv:
Text Formatted Code
$_SCRIPTS->setJavaScriptFile('advanced_editor', '/javascript/advanced_editor.js');
The question is what can we do to make it easy to allow for other editors. The path idea will work for the 2 js files (I am asuming we can combine advanced_editor and storyeditor_fckeditor together).
What should we do for the non file stuff (that is fckeditor related)? I guess we could add a config option for that as well...
Thoughts
Tom
Re: GL 2.0.x theme development
Posted on: 06/29/12 03:44pm
By: suprsidr
I just added:
Text Formatted Code
$_SCRIPTS->setJavaScriptFile('my_javascript', $_CONF['layout_url'].'/js/my_javascript.js');
just above:
Text Formatted Code
// Retrieve any JavaScript libraries, variables and functions
$footercode = $_SCRIPTS->getFooter();
in functions.php theme_site_footer and my_javascript.js is not included anywhere in the page.
-s
Re: GL 2.0.x theme development
Posted on: 06/29/12 04:47pm
By: Laugh
It should have set it unless the file doesn't exist or something (if it returns false then it did not set it).
Do you see any problems with the previous solution?
Tom
Re: GL 2.0.x theme development
Posted on: 06/29/12 06:36pm
By: suprsidr
Being able to set $_CONF options for adv editor path and the specific 4 editors (submitstory_fckeditor.js, submitcomment_fckeditor.js, storyeditor_fckeditor.js, staticpages_fckeditor.js)
would be fine. We could set them in the functions.php theme_init_themename
I just finished rewriting the 4 for ckeditor. Let me combine them into one. Then we can combine in advanced_editor.js as well.
-s
Re: GL 2.0.x theme development
Posted on: 07/22/13 06:35pm
By: Laugh
suprsidr did you every finish this work with the ckeditor?
Re: GL 2.0.x theme development
Posted on: 07/22/13 08:01pm
By: suprsidr
Tom, I cannot remember what I had to do, but I can say that it is indeed fully enabled in that 2.0b site I was working on.
I'll give you full ftp access so you can look.
My latest position is in .net development(yuk!) and the last time I peeked at some of my php projects I felt like it was a long lost best friend. So I do have ambitions to finish that theme. But I remember there were many stumbling blocks you and I had exchanged on. I need to try 2.0 and see where I'm at.
-s