From 63d11a755b3b3f42d9636abef81d662acd181031 Mon Sep 17 00:00:00 2001
From: dignajar
Date: Sat, 29 Aug 2015 02:02:09 -0300
Subject: [PATCH] Improvements on tags
---
admin/controllers/dashboard.php | 2 +-
admin/controllers/edit-page.php | 2 +
admin/controllers/edit-post.php | 8 +++
admin/controllers/new-page.php | 2 +
admin/controllers/new-post.php | 4 ++
admin/views/edit-page.php | 4 +-
admin/views/edit-post.php | 4 +-
admin/views/new-page.php | 4 +-
admin/views/new-post.php | 4 +-
install.php | 30 +++++++++--
kernel/boot/init.php | 2 +
kernel/dbtags.class.php | 67 +++++++++++++++++++++++++
plugins/simplemde/css/editor.css | 7 ---
plugins/simplemde/css/simplemde.min.css | 7 +++
plugins/simplemde/js/simplemde.min.js | 14 ++++++
plugins/simplemde/plugin.php | 14 ++++--
plugins/tags/language/en_US.json | 12 +++++
plugins/tags/plugin.php | 51 +++++++++++++++++++
18 files changed, 213 insertions(+), 25 deletions(-)
create mode 100644 kernel/dbtags.class.php
delete mode 100644 plugins/simplemde/css/editor.css
create mode 100644 plugins/simplemde/css/simplemde.min.css
create mode 100644 plugins/simplemde/js/simplemde.min.js
create mode 100755 plugins/tags/language/en_US.json
create mode 100755 plugins/tags/plugin.php
diff --git a/admin/controllers/dashboard.php b/admin/controllers/dashboard.php
index 63322461..602e33e0 100644
--- a/admin/controllers/dashboard.php
+++ b/admin/controllers/dashboard.php
@@ -33,4 +33,4 @@ foreach($pages as $Page)
if(!$Page->published()) {
array_push($_draftPages, $Page);
}
-}
\ No newline at end of file
+}
diff --git a/admin/controllers/edit-page.php b/admin/controllers/edit-page.php
index 29fa99ec..e591d578 100644
--- a/admin/controllers/edit-page.php
+++ b/admin/controllers/edit-page.php
@@ -26,6 +26,8 @@ function editPage($args)
{
$dbPages->regenerate();
+ //$dbTags->reindexPages( $dbPages->db );
+
Alert::set($Language->g('The changes have been saved'));
Redirect::page('admin', 'edit-page/'.$args['key']);
}
diff --git a/admin/controllers/edit-post.php b/admin/controllers/edit-post.php
index 659b6485..a52ee912 100644
--- a/admin/controllers/edit-post.php
+++ b/admin/controllers/edit-post.php
@@ -7,6 +7,7 @@
function editPost($args)
{
global $dbPosts;
+ global $dbTags;
global $Language;
// Post status, published or draft.
@@ -20,6 +21,9 @@ function editPost($args)
// Edit the post.
if( $dbPosts->edit($args) )
{
+ // Regenerate the database tags
+ $dbTags->reindexPosts( $dbPosts->db );
+
Alert::set($Language->g('The changes have been saved'));
Redirect::page('admin', 'edit-post/'.$args['key']);
}
@@ -32,10 +36,14 @@ function editPost($args)
function deletePost($key)
{
global $dbPosts;
+ global $dbTags;
global $Language;
if( $dbPosts->delete($key) )
{
+ // Regenerate the database tags
+ $dbTags->reindexPosts( $dbPosts->db );
+
Alert::set($Language->g('The post has been deleted successfully'));
Redirect::page('admin', 'manage-posts');
}
diff --git a/admin/controllers/new-page.php b/admin/controllers/new-page.php
index 0dd12df7..0b54d994 100644
--- a/admin/controllers/new-page.php
+++ b/admin/controllers/new-page.php
@@ -24,6 +24,8 @@ function addPage($args)
// Add the page.
if( $dbPages->add($args) )
{
+ //$dbTags->reindexPages( $dbPages->db );
+
Alert::set($Language->g('Page added successfully'));
Redirect::page('admin', 'manage-pages');
}
diff --git a/admin/controllers/new-post.php b/admin/controllers/new-post.php
index f13cba22..92131b52 100644
--- a/admin/controllers/new-post.php
+++ b/admin/controllers/new-post.php
@@ -11,6 +11,7 @@
function addPost($args)
{
global $dbPosts;
+ global $dbTags;
global $Language;
// Page status, published or draft.
@@ -24,6 +25,9 @@ function addPost($args)
// Add the page.
if( $dbPosts->add($args) )
{
+ // Regenerate the database tags
+ $dbTags->reindexPosts( $dbPosts->db );
+
Alert::set($Language->g('Post added successfully'));
Redirect::page('admin', 'manage-posts');
}
diff --git a/admin/views/edit-page.php b/admin/views/edit-page.php
index 7dccff93..3f733924 100644
--- a/admin/views/edit-page.php
+++ b/admin/views/edit-page.php
@@ -6,10 +6,10 @@
-
"+i(f.message+"",!0)+"
";throw f}}var c={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:a,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:a,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:a,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};c.bullet=/(?:[*+-]|\d+\.)/,c.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,c.item=l(c.item,"gm")(/bull/g,c.bullet)(),c.list=l(c.list)(/bull/g,c.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+c.def.source+")")(),c.blockquote=l(c.blockquote)("def",c.def)(),c._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",c.html=l(c.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,c._tag)(),c.paragraph=l(c.paragraph)("hr",c.hr)("heading",c.heading)("lheading",c.lheading)("blockquote",c.blockquote)("tag","<"+c._tag)("def",c.def)(),c.normal=s({},c),c.gfm=s({},c.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),c.gfm.paragraph=l(c.paragraph)("(?!","(?!"+c.gfm.fences.source.replace("\\1","\\2")+"|"+c.list.source.replace("\\1","\\3")+"|")(),c.tables=s({},c.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=c,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,i,o,l,a,s,u,h,f,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")
+});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},h=0;h ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),l=o[2],this.tokens.push({type:"list_start",ordered:l.length>1}),o=o[0].match(this.rules.item),r=!1,f=o.length,h=0;f>h;h++)s=o[h],u=s.length,s=s.replace(/^ *([*+-]|\d+\.) +/,""),~s.indexOf("\n ")&&(u-=s.length,s=this.options.pedantic?s.replace(/^ {1,4}/gm,""):s.replace(new RegExp("^ {1,"+u+"}","gm"),"")),this.options.smartLists&&h!==f-1&&(a=c.bullet.exec(o[h+1])[0],l===a||l.length>1&&a.length>1||(e=o.slice(h+1).join("\n")+e,h=f-1)),i=r||/\n\n(?!\s*$)/.test(s),h!==f-1&&(r="\n"===s.charAt(s.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(s,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},h=0;h])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:a,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:a,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=l(h.link)("inside",h._inside)("href",h._href)(),h.reflink=l(h.reflink)("inside",h._inside)(),h.normal=s({},h),h.pedantic=s({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=s({},h.normal,{escape:l(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=s({},h.gfm,{br:l(h.br)("{2,}","*")(),text:l(h.gfm.text)("{2,}","*")()}),t.rules=h,t.output=function(e,n,r){var i=new t(n,r);return i.output(e)},t.prototype.output=function(e){for(var t,n,r,o,l="";e;)if(o=this.rules.escape.exec(e))e=e.substring(o[0].length),l+=o[1];else if(o=this.rules.autolink.exec(e))e=e.substring(o[0].length),"@"===o[2]?(n=this.mangle(":"===o[1].charAt(6)?o[1].substring(7):o[1]),r=this.mangle("mailto:")+n):(n=i(o[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(o=this.rules.url.exec(e))){if(o=this.rules.tag.exec(e))!this.inLink&&/^/i.test(o[0])&&(this.inLink=!1),e=e.substring(o[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(o[0]):i(o[0]):o[0];else if(o=this.rules.link.exec(e))e=e.substring(o[0].length),this.inLink=!0,l+=this.outputLink(o,{href:o[2],title:o[3]}),this.inLink=!1;else if((o=this.rules.reflink.exec(e))||(o=this.rules.nolink.exec(e))){if(e=e.substring(o[0].length),t=(o[2]||o[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=o[0].charAt(0),e=o[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(o,t),this.inLink=!1}else if(o=this.rules.strong.exec(e))e=e.substring(o[0].length),l+=this.renderer.strong(this.output(o[2]||o[1]));else if(o=this.rules.em.exec(e))e=e.substring(o[0].length),l+=this.renderer.em(this.output(o[2]||o[1]));else if(o=this.rules.code.exec(e))e=e.substring(o[0].length),l+=this.renderer.codespan(i(o[2],!0));else if(o=this.rules.br.exec(e))e=e.substring(o[0].length),l+=this.renderer.br();else if(o=this.rules.del.exec(e))e=e.substring(o[0].length),l+=this.renderer.del(this.output(o[1]));else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),l+=this.renderer.text(i(this.smartypants(o[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(o[0].length),n=i(o[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=i(t.href),r=t.title?i(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,i(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;r>i;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+=""+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?''+(n?e:i(e,!0))+"\n
\n":""+(n?e:i(e,!0))+"\n
"},n.prototype.blockquote=function(e){return"\n"+e+"
\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"\n"},n.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+""+n+">\n"},n.prototype.listitem=function(e){return""+e+"\n"},n.prototype.paragraph=function(e){return""+e+"
\n"},n.prototype.table=function(e,t){return"\n"},n.prototype.tablerow=function(e){return"\n"+e+"
\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+""+n+">\n"},n.prototype.strong=function(e){return""+e+""},n.prototype.em=function(e){return""+e+""},n.prototype.codespan=function(e){return""+e+"
"},n.prototype.br=function(){return this.options.xhtml?"
":"
"},n.prototype.del=function(e){return""+e+""},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(o(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='"+n+""},n.prototype.image=function(e,t,n){var r='":">"},n.prototype.text=function(e){return e},r.parse=function(e,t,n){var i=new r(t,n);return i.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i,o="",l="";for(n="",e=0;e=12&&(a=i-12,l="pm"),0==a&&(a=12),o=10>o?"0"+o:o,n.innerHTML="Autosaved: "+a+":"+o+" "+l}setTimeout(function(){t.autosave()},this.options.autosave.delay||1e4)},SimpleMDE.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){for(var t=0;tshortLanguage();
$pluginPath = $this->htmlPath();
- $html = '';
- $html .= '';
- $html .= '';
+ $html .= '';
+ $html .= '';
+
+ //$html = '';
+ //$html .= '';
+ //$html .= '';
+
}
@@ -50,14 +54,14 @@ class pluginsimpleMDE extends Plugin {
$html .=
'var simplemde = new SimpleMDE({
element: document.getElementById("jscontent"),
- status: true,
+ status: false,
toolbarTips: true,
toolbarGuideIcon: true,
autofocus: true,
lineWrapping: false,
indentWithTabs: true,
tabSize: 4,
- spellChecker: true
+ spellChecker: false
});';
$html .= '}); ';
}
diff --git a/plugins/tags/language/en_US.json b/plugins/tags/language/en_US.json
new file mode 100755
index 00000000..6bfc0e5b
--- /dev/null
+++ b/plugins/tags/language/en_US.json
@@ -0,0 +1,12 @@
+{
+ "plugin-data":
+ {
+ "name": "Tags list",
+ "description": "Shows all tags.",
+ "author": "Bludit",
+ "email": "",
+ "website": "http://www.bludit.com",
+ "version": "0.1",
+ "releaseDate": "2015-08-02"
+ }
+}
\ No newline at end of file
diff --git a/plugins/tags/plugin.php b/plugins/tags/plugin.php
new file mode 100755
index 00000000..10f37185
--- /dev/null
+++ b/plugins/tags/plugin.php
@@ -0,0 +1,51 @@
+dbFields = array(
+ 'label'=>'Tags'
+ );
+ }
+
+ public function form()
+ {
+ global $Language;
+
+ $html = '';
+ $html .= 'Plugin label';
+ $html .= '';
+ $html .= '
';
+
+ return $html;
+ }
+
+ public function siteSidebar()
+ {
+ global $Language;
+ global $dbTags;
+
+ $html = '';
+
+ return $html;
+ }
+}