From 3a12176bbb266c48e9a7efc78c63273912a216b4 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 25 Mar 2022 09:18:29 +0100 Subject: [PATCH] furl page short title --- core/module/page/page.php | 3 +- core/module/page/vendor/furl/LICENSE | 21 ++++++ core/module/page/vendor/furl/README.md | 4 ++ core/module/page/vendor/furl/inc.json | 3 + core/module/page/vendor/furl/jquery.furl.js | 76 +++++++++++++++++++++ core/module/page/view/edit/edit.js.php | 3 +- 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 core/module/page/vendor/furl/LICENSE create mode 100644 core/module/page/vendor/furl/README.md create mode 100644 core/module/page/vendor/furl/inc.json create mode 100644 core/module/page/vendor/furl/jquery.furl.js diff --git a/core/module/page/page.php b/core/module/page/page.php index 092083c0..7eff20eb 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -540,7 +540,8 @@ class page extends common { $this->addOutput([ 'title' => $this->getData(['page', $this->getUrl(2), 'title']), 'vendor' => [ - 'tinymce' + 'tinymce', + 'furl' ], 'view' => 'edit' ]); diff --git a/core/module/page/vendor/furl/LICENSE b/core/module/page/vendor/furl/LICENSE new file mode 100644 index 00000000..5f86a4d6 --- /dev/null +++ b/core/module/page/vendor/furl/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Vedat Taylan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/core/module/page/vendor/furl/README.md b/core/module/page/vendor/furl/README.md new file mode 100644 index 00000000..2386a5ff --- /dev/null +++ b/core/module/page/vendor/furl/README.md @@ -0,0 +1,4 @@ +# furl +jQuery Furl (Friendly URL) Plugin 1.0.0 + +Usage : $('#InputID').furl({id:'ReplaceInputID', seperate (optional) : '_' }); diff --git a/core/module/page/vendor/furl/inc.json b/core/module/page/vendor/furl/inc.json new file mode 100644 index 00000000..7ef795a0 --- /dev/null +++ b/core/module/page/vendor/furl/inc.json @@ -0,0 +1,3 @@ +[ + "jquery.furl.js" +] \ No newline at end of file diff --git a/core/module/page/vendor/furl/jquery.furl.js b/core/module/page/vendor/furl/jquery.furl.js new file mode 100644 index 00000000..58a13808 --- /dev/null +++ b/core/module/page/vendor/furl/jquery.furl.js @@ -0,0 +1,76 @@ +/* + * jQuery Furl (Friendly URL) Plugin 1.0.0 + * + * Author : Vedat Taylan + * + * Year : 2018 + * Usage : $('#InputID').furl({id:'ReplaceInputID', seperate (optional) : '_' }); + */ +(function ($, undefined) { + function Furl() { + this.defaults = { + seperate: '-' + }; + } + Furl.prototype = { + init: function (target, options) { + var $this = this; + options = $.extend({}, $this.defaults, options); + + $(target).keyup(function () { + var url = urlReplace($(this).val(), options); + var $element = $('#' + options.id); + + if ($element.length > 0) { + var tagName = $element.get(0).tagName; + switch (tagName) { + case 'INPUT': + $element.val(url); + break; + default: + $element.text(url); + } + } + }); + } + }; + function urlReplace(url, options) { + return url.toLowerCase() + .replace(/ä/g, 'ae') + .replace(/Ä/g, 'ae') + .replace(/ğ/g, 'g') + .replace(/ü/g, 'u') + .replace(/ş/g, 's') + .replace(/ı/g, 'i') + .replace(/ö/g, 'o') + .replace(/ç/g, 'c') + .replace(/Ğ/g, 'g') + .replace(/Ü/g, 'u') + .replace(/Ş/g, 's') + .replace(/I/g, 'i') + .replace(/İ/g, 'i') + .replace(/Ö/g, 'o') + .replace(/Ç/g, 'c') + + .replace(/[^a-z0-9\s-]/g, "") + .replace(/[\s-]+/g, " ") + .replace(/^\s+|\s+$/g, "") + .replace(/\s/g, "-") + + .replace(/^\s+|\s+$/g, "") + .replace(/[_|\s]+/g, "-") + .replace(/[^a-z\u0400-\u04FF0-9-]+/g, "") + .replace(/[-]+/g, "-") + .replace(/^-+|-+$/g, "") + .replace(/[-]+/g, options.seperate); + } + + $.furl = new Furl(); + $.furl.version = "1.0.0"; + + $.fn.furl = function (options) { + return this.each(function () { + $.furl.init(this, options); + }); + }; +})(jQuery); diff --git a/core/module/page/view/edit/edit.js.php b/core/module/page/view/edit/edit.js.php index fd8cd195..0dcdcc9f 100644 --- a/core/module/page/view/edit/edit.js.php +++ b/core/module/page/view/edit/edit.js.php @@ -253,7 +253,8 @@ $( document ).ready(function() { $("#pageEditPosition").val(positionInitial); } - + // Permalink + $('#pageEditTitle').furl({id:'pageEditShortTitle', seperate: '_' }); });