From 678eb853d789e4a97dd9e809dc8ac643019c69e3 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Tue, 2 Jun 2015 22:17:09 -0300 Subject: [PATCH] New features --- features.txt | 19 ++-------- kernel/abstract/plugin.class.php | 10 +++++ kernel/boot/rules/70.build_pages.php | 8 +++- kernel/boot/rules/80.plugins.php | 19 +++++++--- kernel/boot/site.php | 6 --- kernel/page.class.php | 23 ++++++------ kernel/post.class.php | 22 ++++++++--- plugins/about/plugin.php | 6 --- plugins/opengaph/plugin.php | 55 ++++++++++++++++++++++++++++ 9 files changed, 118 insertions(+), 50 deletions(-) create mode 100644 plugins/opengaph/plugin.php diff --git a/features.txt b/features.txt index 6c854fb1..e15bf8c9 100644 --- a/features.txt +++ b/features.txt @@ -5,12 +5,13 @@ Diego Najar Implementar - Links a Google+, Facebook y Twitter - Plugins -- Plugins SEO, description, opengaph, etc.. +- Plugins SEO, description, opengraph, etc.. - Comentarios - Notificaciones -- Dashboard, parecido a Nibbleblog, me gusta. - iPhone app - Cloud +- ver casos de errores, filtros url iguales, con una / +- No permitir en filtros url iguales, agregar / al comienzo y final - Usuarios de lectura ?, no vale la pena, y hay que hacer mas controles a nivel de administracion. - Implementar algun limpiador** @@ -27,14 +28,6 @@ AllowOverride All ———— -Objetos tipo estáticos, que empiecen con la letra h o la palabra helper. - -hText:: -hUrl:: - -helperText:: -helperUrl:: - find . -type f -name "*.php" -print0 | xargs -0 sed -i 's/Text/helperText/g' find . -type f -name "*.php" -print0 | xargs -0 sed -i 's/Url/helperUrl/g' @@ -52,17 +45,13 @@ Si cambia el parent verificar parent mover directorio adentro del parent - - Editar usuario 1- Usuario logueado 2- Ver si el usuario es administrador o si es el mismo usuario que se esta editando. - ————————— - -- Las Friendly URL son Case sensitive. +- Friendly URL son Case sensitive. ————————— Editando a mano diff --git a/kernel/abstract/plugin.class.php b/kernel/abstract/plugin.class.php index 3aa1a97e..ff3f857c 100644 --- a/kernel/abstract/plugin.class.php +++ b/kernel/abstract/plugin.class.php @@ -115,6 +115,16 @@ class Plugin { return false; } + public function onAdminHead() + { + return false; + } + + public function onAdminBody() + { + return false; + } + public function onSidebar() { return false; diff --git a/kernel/boot/rules/70.build_pages.php b/kernel/boot/rules/70.build_pages.php index 606c32ba..db858b01 100644 --- a/kernel/boot/rules/70.build_pages.php +++ b/kernel/boot/rules/70.build_pages.php @@ -163,5 +163,11 @@ if($Url->notFound()===false) } } +if($Url->notFound()) +{ + $Url->setWhereAmI('page'); + $Page = new Page('error'); +} + // Build all pages -build_all_pages(); +build_all_pages(); \ No newline at end of file diff --git a/kernel/boot/rules/80.plugins.php b/kernel/boot/rules/80.plugins.php index aa0349bf..c0a77a2e 100644 --- a/kernel/boot/rules/80.plugins.php +++ b/kernel/boot/rules/80.plugins.php @@ -3,7 +3,9 @@ $plugins = array( 'onSiteHead'=>array(), 'onSiteBody'=>array(), - 'onSidebar'=>array() + 'onSidebar'=>array(), + 'onAdminHead'=>array(), + 'onAdminBody'=>array() ); function build_plugins() @@ -13,12 +15,13 @@ function build_plugins() // List plugins directories $list = Filesystem::listDirectories(PATH_PLUGINS); - // Get declared clasess before load plugins clasess + // Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess. $currentDeclaredClasess = get_declared_classes(); - // Load each clasess - foreach($list as $pluginPath) + // Load each plugin clasess + foreach($list as $pluginPath) { include($pluginPath.'/plugin.php'); + } // Get plugins clasess loaded $pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess); @@ -35,9 +38,13 @@ function build_plugins() if($Plugin->onSidebar()!==false) array_push($plugins['onSidebar'], $Plugin); + + if($Plugin->onAdminHead()!==false) + array_push($plugins['onAdminHead'], $Plugin); + + if($Plugin->onAdminBody()!==false) + array_push($plugins['onAdminBody'], $Plugin); } } build_plugins(); - -?> diff --git a/kernel/boot/site.php b/kernel/boot/site.php index 47548b14..a8f39bb4 100644 --- a/kernel/boot/site.php +++ b/kernel/boot/site.php @@ -6,12 +6,6 @@ include(PATH_RULES.'70.build_pages.php'); include(PATH_RULES.'80.plugins.php'); include(PATH_RULES.'99.header.php'); -if($Url->notFound()) -{ - $Url->setWhereAmI('page'); - $Page = new Page('error'); -} - // Theme init.php if( Sanitize::pathFile(PATH_THEMES, $Site->theme().'/init.php') ) include(PATH_THEMES.$Site->theme().'/init.php'); diff --git a/kernel/page.class.php b/kernel/page.class.php index c3ea73ab..6fed7cd0 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -109,27 +109,28 @@ class Page extends fileContent } // Returns the page permalink. - public function permalink() + public function permalink($absolute=false) { global $Url; + global $Site; - $path = ''; - $slug = $this->slug(); - $parent = $this->parent(); - $filter = ltrim($Url->filters('page'), '/'); + $url = trim($Site->url(),'/'); + $key = $this->key(); + $filter = trim($Url->filters('page'), '/'); + $htmlPath = trim(HTML_PATH_ROOT,'/'); - if($Url->filters('page')==HTML_PATH_ROOT) { - $path = HTML_PATH_ROOT; + if(empty($filter)) { + $tmp = $key; } else { - $path = HTML_PATH_ROOT.$filter.'/'; + $tmp = $filter.'/'.$key; } - if($parent===false) { - return $path.$slug; + if($absolute) { + return $url.'/'.$tmp; } - return $path.$parent.'/'.$slug; + return $htmlPath.'/'.$tmp; } public function parentKey() diff --git a/kernel/post.class.php b/kernel/post.class.php index 461e3f4d..39357a9c 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -99,16 +99,28 @@ class Post extends fileContent return $this->getField('key'); } - public function permalink() + public function permalink($absolute=false) { global $Url; + global $Site; - $filter = ltrim($Url->filters('post'), '/'); + $url = trim($Site->url(),'/'); + $key = $this->key(); + $filter = trim($Url->filters('post'), '/'); + $htmlPath = trim(HTML_PATH_ROOT,'/'); - if($Url->filters('post')==HTML_PATH_ROOT) - return HTML_PATH_ROOT.$this->slug(); + if(empty($filter)) { + $tmp = $key; + } + else { + $tmp = $filter.'/'.$key; + } - return HTML_PATH_ROOT.$filter.$this->slug(); + if($absolute) { + return $url.'/'.$tmp; + } + + return $htmlPath.'/'.$tmp; } } diff --git a/plugins/about/plugin.php b/plugins/about/plugin.php index 1c337617..6fe52a5b 100644 --- a/plugins/about/plugin.php +++ b/plugins/about/plugin.php @@ -8,12 +8,6 @@ class pluginAbout extends Plugin { 'title'=>'', 'description'=>'' ); - } - - public function onSiteHead() - { - $html = 'Blog – Layout Examples – Pure'; - return $html; } diff --git a/plugins/opengaph/plugin.php b/plugins/opengaph/plugin.php new file mode 100644 index 00000000..e4653d5a --- /dev/null +++ b/plugins/opengaph/plugin.php @@ -0,0 +1,55 @@ +dbFields = array( + 'title'=>'Open Graph', + 'description'=>'' + ); + } + + public function onSiteHead() + { + global $Url, $Site; + global $Post, $Page; + + $og = array( + 'locale' =>$Site->locale(), + 'type' =>'website', + 'title' =>$Site->title(), + 'description' =>$Site->description(), + 'url' =>$Site->url(), + 'image' =>'', + 'site_name' =>$Site->title() + ); + + switch($Url->whereAmI()) + { + case 'post': + $og['type'] = 'article'; + $og['title'] = $Post->title().' | '.$og['title']; + $og['description'] = $Post->description(); + $og['url'] = $Post->permalink(true); + break; + case 'page': + $og['type'] = 'article'; + $og['title'] = $Page->title().' | '.$og['title']; + $og['description'] = $Page->description(); + $og['url'] = $Page->permalink(true); + break; + } + + $html = PHP_EOL.''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + + return $html; + } +} \ No newline at end of file