From: Radek Czajka Date: Tue, 7 Dec 2010 13:29:47 +0000 (+0100) Subject: #977: slugify tool X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/e6e1017c531add5a7a5cbd4e24dc38fce4da0ea0?ds=sidebyside #977: slugify tool --- diff --git a/apps/toolbar/fixtures/initial_data.yaml b/apps/toolbar/fixtures/initial_data.yaml index 21feb1f4..ba3148a6 100644 --- a/apps/toolbar/fixtures/initial_data.yaml +++ b/apps/toolbar/fixtures/initial_data.yaml @@ -684,6 +684,17 @@ tooltip: "frazy w j\u0119zykach innych ni\u017C polski/definiendum w przypisie" model: toolbar.button pk: 46 +- fields: + accesskey: '' + group: [2] + label: slug + link: '' + params: '[]' + scriptlet: slugify + slug: slug + tooltip: slugifikacja + model: toolbar.button + pk: 105 - fields: accesskey: '' group: [1] @@ -980,4 +991,7 @@ \r\n\r\n\r\n\r\n\r\n\r\n\r\npanel.fireEvent('contentChanged');"} model: toolbar.scriptlet pk: insert_stanza +- fields: {code: '-'} + model: toolbar.scriptlet + pk: slugify diff --git a/redakcja/static/js/button_scripts.js b/redakcja/static/js/button_scripts.js index ff17eea4..ef2b794d 100644 --- a/redakcja/static/js/button_scripts.js +++ b/redakcja/static/js/button_scripts.js @@ -282,6 +282,12 @@ function ScriptletCenter() done(output, move_forward, move_up); }.bind(this); + + this.scriptlets['slugify'] = function(context, params, text, move_forward, move_up, done) + { + done(slugify(text.replace(/_/g, '-')), move_forward, move_up); + }.bind(this); + } ScriptletCenter.prototype.callInteractive = function(opts) {