Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
spf_js - JavaScript management - create, edit, delete, export to file
A JavaScript plugin – a combination of stm_javascript and rvm_css – thanks to both original authors.
Create, edit and delete scripts in Textpattern admin and export on save to external files – with support for Minify.
Re-written for Textpattern 4.5.1.
Requires Textpattern 4.5.1 and PHP 5 (and Minify for minification).
- Download for Textpattern >= 4.5.1
- Download for Textpattern <= 4.4.1
- Textpack
- Minify
Many thanks to Jukka for invaluable feedback.
—
Version history
0.51 – November 2012- Fixed issue setting prefs in 4.5.x.
- Rewritten for Textpattern 4.5.×.
- Italian Textpack added (thanks Marco);
- Last version to support Textpattern 4.4.1 and below.
- Added Minify support.
- Fixed delete issue with script names containing dots (thanks Yiannis).
- French & German Textpacks added (thanks Patrick & Uli);
- added syntax highlighting (via spf_codemirror).
- first release.
—
Tags
<txp:spf_js />
(embeds the default JavaScript file)
<txp:spf_js name="myscript" />
(embeds the JavaScript file named “myscript”)
HTML output
<script src="http://mysite.com/js/myscript.js"></script>
“type” attribute
By default the plugin outputs a script tag without the “type” attribute (required in XHTML/HTML4 but optional in HTML5).
To include a “type” attribute just use the type=“1” argument:
<txp:spf_js name="myscript" type="1" />
- will output:
<script type="text/javascript" src="http://mysite.com/js/myscript.js"></script>
“min” attribute
You can now minify your JavaScripts dynamically – requires Minify installed in the standard (DocumentRoot/min) location.
<txp:spf_js name="myscript" min="1" />
Outputs:
<script src="http://mysite.com/min/f=js/myscript.js"></script>
(Works with or without the “type” attribute.)
—
stm_javascript
If stm_javascript is installed and activated you will see two JavaScript tabs in Presentation – one named ‘Javascript’ (stm_javascript – with lowercase ‘s’) and another ‘JavaScript’ (spf_js – uppercase ‘S’).
You can copy and paste scripts from stm_javascript to spf_js – and then disable stm_javascript. It’s not advisable to run both plugins simultaneously.
—
Minify
.. is very easy to install: just download, unzip, and upload the ‘min’ directory to your web root.
You may have to tweak the config.php file .. e.g. $min_cachePath = ‘my_web_root/textpattern/tmp’;
Last edited by spiffin (2012-11-07 20:40:47)
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
Very interesting.
Will there be an option to concatenate several files and minifier all?
Because that is what is missing in rvm_css and I regret.
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
I’m so looking forward to this one. Thanks for your work Simon.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
sacripant wrote:
Will there be an option to concatenate several files and minifier all?
Because that is what is missing in rvm_css and I regret.
Don’t like to plug my own junk, but well, there is rah_minify plugin. It’s a wrapper for a YUIcompressor and some other libraries. Slightly more advanced and configuration heavy than my other plugins. If your server has Java and you have knowledge of CLI, basic PHP know-how and what file paths are, then it’s an option.
As it works as a wrapper that minifies flat files (it is not for database stored styles), it can also work with rvm_css and spf_javascript as those create flat files.
Last edited by Gocom (2012-04-10 18:08:30)
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
sacripant wrote:
Will there be an option to concatenate several files and minifier all?
Not in the first version — as Jukka mentioned his rah_minify is great if you’re running Java — and, if not, Minify is a breeze to set up and works very well.
Offline
#6 2012-04-20 20:23:27
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: spf_js - JavaScript management - create, edit, delete, export to file
Simon, though I saw there’s a whole lot of changes you’ve made, the file name, the version number inside the download and the sidebar entry over on TXP Resources is still numbered 0.1. That might keep people who have the real v0.1 from downloading the new one.
Last edited by uli (2012-04-20 20:40:59)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#7 2012-04-20 21:01:37
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: spf_js - JavaScript management - create, edit, delete, export to file
German language pack:
#@spf_js
#@language de-de
spf_javascript => JavaScript
spf_js_dir => JavaScript-Verzeichnis
spf_script_name => Name dieses Scripts:
spf_edit_script => Sie bearbeiten das Script
spf_copy_script => Script kopieren als:
spf_all_scripts => Alle Scripts
spf_create_new_script => Neues Script erstellen
spf_script_created => Script <strong>»{name}«</strong> wurde erstellt.
spf_script_exists => Script <strong>»{name}«</strong> gibt es bereits, bitte vergeben Sie einen anderen Namen.
spf_script_name_required => Bitte vergeben Sie einen Namen für Ihr Script.
spf_script_updated => Script <strong>»{name}«</strong> wurde aktualisiert.
spf_script_deleted => Script <strong>»{name}«</strong> wurde gelöscht.
spf_cannot_delete_default_script => Script <strong>»default«</strong> konnte nicht gelöscht werden.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
works wonderfuly. Thanks so much for your work Simon
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
Hi Simon
Is the plugin parsed (can we include txp tag inside javascript file) ?
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
uli wrote:
Simon, though I saw there’s a whole lot of changes you’ve made, the file name, the version number inside the download and the sidebar entry over on TXP Resources is still numbered 0.1. That might keep people who have the real v0.1 from downloading the new one.
Hi Uli
There wasn’t another version – spf_javascript was pulled immediately – spf_js is completely rewritten therefore new name and version 0.1.
Offline
#11 2012-04-21 11:30:04
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: spf_js - JavaScript management - create, edit, delete, export to file
spiffin wrote:
spf_javascript was pulled immediately
Well, then I’m the lucky owner of the Blue Mauritius :))
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: spf_js - JavaScript management - create, edit, delete, export to file
… fr-fr Textpack file:
#@spf_js #@language fr-fr spf_javascript => JavaScript spf_js_dir => Répertoire JavaScript spf_script_name => Nom de ce script spf_edit_script => Vous éditez le script spf_copy_script => …ou copier le script sous spf_all_scripts => Tous les scripts spf_create_new_script => Créer un nouveau script spf_script_created => Le script <strong>{name}</strong> a été créé. spf_script_exists => Le script <strong>{name}</strong> existe déjà. spf_script_name_required => Veuillez renseigner un nom pour votre script. spf_script_updated => Le script <strong>{name}</strong> a été mis à jour. spf_script_deleted => Le script <strong>{name}</strong> a été supprimé. spf_cannot_delete_default_script => Le script <strong>default</strong> ne peut pas être supprimé.
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline