Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-04-09 22:26:25

spiffin
Plugin Author
From: London, UK
Registered: 2004-06-08
Posts: 79
Website

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).

- Instructions

- 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.

0.5 – November 2012

  • Rewritten for Textpattern 4.5.×.

0.41 – June 2012

  • Italian Textpack added (thanks Marco);
  • Last version to support Textpattern 4.4.1 and below.

0.4 – May 2012

0.3 – May 2012

  • Fixed delete issue with script names containing dots (thanks Yiannis).

0.2 – April 2012

  • French & German Textpacks added (thanks Patrick & Uli);
  • added syntax highlighting (via spf_codemirror).

0.1 – April 2012

  • 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

#2 2012-04-10 14:28:21

sacripant
Plugin Author
From: Dakar – Sénégal – Africa
Registered: 2008-06-01
Posts: 358
Website

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

#3 2012-04-10 17:13:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,970
Website

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.org | neme-imca.org | hblack.net | LABS

Offline

#4 2012-04-10 18:04:10

Gocom
Developer
Registered: 2006-07-14
Posts: 4,476
Website

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)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#5 2012-04-11 22:42:01

spiffin
Plugin Author
From: London, UK
Registered: 2004-06-08
Posts: 79
Website

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/Köln
Registered: 2006-08-15
Posts: 3,085

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/Köln
Registered: 2006-08-15
Posts: 3,085

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

#8 2012-04-21 07:00:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,970
Website

Re: spf_js - JavaScript management - create, edit, delete, export to file

works wonderfuly. Thanks so much for your work Simon


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#9 2012-04-21 09:52:55

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,140
Website

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

#10 2012-04-21 10:42:31

spiffin
Plugin Author
From: London, UK
Registered: 2004-06-08
Posts: 79
Website

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

Board footer

Powered by FluxBB