Răsfoiți Sursa

Blog section working.

Iñigo Valentin 8 ani în urmă
părinte
comite
37c652b783

+ 1 - 3
.gitignore

@@ -21,12 +21,10 @@ remoteadmin
 www-admin/redirect_s.php
 
 #SQL data
-sql/dbusers.sql
-sql/*row*.sql
 sql/CUSTOM_ROWS.SQL
+sql/DEBUG_ROWS.SQL
 
 #Passwords file
-sql/dbpasswords.sql
 www/.htpasswd
 www-admin/.htpasswd
 www/.htaccess_local

+ 23 - 13
sql/00_STRUCTURE.SQL

@@ -52,7 +52,17 @@ CREATE TABLE social(
     id       INT           AUTO_INCREMENT  PRIMARY KEY,
     idx      INT           NOT NULL        UNIQUE,
     visible  BOOLEAN       NOT NULL        DEFAULT 1,
-    title    VARCHAR(32)   NOT NULL        REFERENCES text.id,
+    title    VARCHAR(32)   NOT NULL        UNIQUE       REFERENCES text.id,
+    icon     VARCHAR(16)   NOT NULL,
+    url      VARCHAR(256)  NOT NULL
+);
+
+CREATE TABLE share(
+    id       INT           AUTO_INCREMENT      PRIMARY KEY,
+    idx      INT           NOT NULL            UNIQUE,
+    visible  BOOLEAN       NOT NULL            DEFAULT 1,
+    title    VARCHAR(32)   NOT NULL            UNIQUE       REFERENCES text.id,
+    text     VARCHAR(32)   REFERENCES text.id,
     icon     VARCHAR(16)   NOT NULL,
     url      VARCHAR(256)  NOT NULL
 );
@@ -75,10 +85,10 @@ CREATE TABLE post_tag (
 );
 
 CREATE TABLE post_image (
-    id      INT           NOT NULL,
-    post    INT           NOT NULL  REFERENCES post.id,
-    image   VARCHAR(200)  NOT NULL,
-    PRIMARY KEY(id, post)
+    id     INT           AUTO_INCREMENT  PRIMARY KEY,
+    post   INT           NOT NULL        REFERENCES post.id,
+    idx    INT           NOT NULL,
+    image  VARCHAR(200)  NOT NULL
 );
 
 CREATE TABLE post_comment (
@@ -148,17 +158,17 @@ CREATE TABLE project_url_type (
 );
 
 CREATE TABLE project_url (
-    project  INT            NOT NULL  REFERENCES project.id,
-    type     VARCHAR(1)     NOT NULL  REFERENCES project_url_type,
-    url      VARCHAR(1024)  NOT NULL,
-    PRIMARY KEY (project, type)
+    id       INT            AUTO_INCREMENT  PRIMARY KEY,
+    project  INT            NOT NULL        REFERENCES project.id,
+    type     VARCHAR(1)     NOT NULL        REFERENCES project_url_type,
+    url      VARCHAR(1024)  NOT NULL
 );
 
 CREATE TABLE project_image (
-    id       INT           NOT NULL,
-    project  INT           NOT NULL  REFERENCES project.id,
-    image    VARCHAR(200)  NOT NULL,
-    PRIMARY KEY(id, project)
+    id       INT           AUTO_INCREMENT  PRIMARY KEY,
+    project  INT           NOT NULL        REFERENCES project.id,
+    idx      INT           NOT NULL,
+    image    VARCHAR(200)  NOT NULL
 );
 
 CREATE TABLE project_tag (

+ 1 - 0
sql/01_PERMISSIONS.SQL

@@ -22,6 +22,7 @@
 --GRANT SELECT ON         iv.project_version_type TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
 --GRANT SELECT, INSERT ON iv.project_comment      TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
 --GRANT SELECT ON         iv.settings             TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
+--GRANT SELECT ON         iv.share                TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
 --GRANT SELECT, INSERT ON iv.stat_view            TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
 --GRANT SELECT, INSERT ON iv.stat_visit           TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';
 --GRANT SELECT ON         iv.social               TO 'ivext'@'localhost' IDENTIFIED BY 'XXX';

+ 43 - 0
sql/02_DATA.SQL

@@ -97,6 +97,49 @@ INSERT INTO text VALUES ('SOCIAL_LINKEDIN', 'es', 'SOCIAL', 'LinkedIn', null);
 INSERT INTO text VALUES ('SOCIAL_LINKEDIN', 'en', 'SOCIAL', 'LinkedIn', null);
 INSERT INTO text VALUES ('SOCIAL_LINKEDIN', 'eu', 'SOCIAL', 'LinkedIn', null);
 
+-- SHARE
+INSERT INTO text VALUES ('SHARE_FACEBOOK', 'es', 'SHARE', 'Facebook', null);
+INSERT INTO text VALUES ('SHARE_FACEBOOK', 'en', 'SHARE', 'Facebook', null);
+INSERT INTO text VALUES ('SHARE_FACEBOOK', 'eu', 'SHARE', 'Facebook', null);
+INSERT INTO text VALUES ('SHARE_TWITTER', 'es', 'SHARE', 'Twitter', null);
+INSERT INTO text VALUES ('SHARE_TWITTER', 'en', 'SHARE', 'Twitter', null);
+INSERT INTO text VALUES ('SHARE_TWITTER', 'eu', 'SHARE', 'Twitter', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE', 'es', 'SHARE', 'Google +', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE', 'en', 'SHARE', 'Google +', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE', 'eu', 'SHARE', 'Google +', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM', 'es', 'SHARE', 'Telegram', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM', 'en', 'SHARE', 'Telegram', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM', 'eu', 'SHARE', 'Telegram', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN', 'es', 'SHARE', 'LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN', 'en', 'SHARE', 'LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN', 'eu', 'SHARE', 'LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE', 'es', 'SHARE', 'VKontakte', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE', 'en', 'SHARE', 'VKontakte', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE', 'eu', 'SHARE', 'VKontakte', null);
+INSERT INTO text VALUES ('SHARE_FACEBOOK_DESC', 'es', 'SHARE', 'Publicar en Facebook', null);
+INSERT INTO text VALUES ('SHARE_FACEBOOK_DESC', 'en', 'SHARE', 'Share on Facebook', null);
+INSERT INTO text VALUES ('SHARE_FACEBOOK_DESC', 'eu', 'SHARE', 'Facebook', null);
+INSERT INTO text VALUES ('SHARE_TWITTER_DESC', 'es', 'SHARE', 'Publicar en Twitter', null);
+INSERT INTO text VALUES ('SHARE_TWITTER_DESC', 'en', 'SHARE', 'Share on Twitter', null);
+INSERT INTO text VALUES ('SHARE_TWITTER_DESC', 'eu', 'SHARE', 'Twitter', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE_DESC', 'es', 'SHARE', 'Publicar en Google +', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE_DESC', 'en', 'SHARE', 'Share on Google +', null);
+INSERT INTO text VALUES ('SHARE_GOOGLE_DESC', 'eu', 'SHARE', 'Google +', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM_DESC', 'es', 'SHARE', 'Publicar en Telegram', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM_DESC', 'en', 'SHARE', 'Share on Telegram', null);
+INSERT INTO text VALUES ('SHARE_TELEGRAM_DESC', 'eu', 'SHARE', 'Telegram', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN_DESC', 'es', 'SHARE', 'Publicar en LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN_DESC', 'en', 'SHARE', 'Share on LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_LINKEDIN_DESC', 'eu', 'SHARE', 'LinkedIn', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE_DESC', 'es', 'SHARE', 'Publicar en VKontakte', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE_DESC', 'en', 'SHARE', 'Share on VKontakte', null);
+INSERT INTO text VALUES ('SHARE_VKONTAKTE_DESC', 'eu', 'SHARE', 'VKontakte', null);
+INSERT INTO share VALUES (1, 1, 1, 'SHARE_FACEBOOK', 'SHARE_FACEBOOK_DESC', 'facebook.gif', 'https://www.facebook.com/sharer/sharer.php?u=');
+INSERT INTO share VALUES (2, 2, 1, 'SHARE_TWITTER', 'SHARE_TWITTER_DESC', 'twitter.gif', 'https://twitter.com/share?url=');
+INSERT INTO share VALUES (3, 3, 1, 'SHARE_GOOGLE', 'SHARE_GOOGLE_DESC', 'google.gif', 'https://plus.google.com/share?url=');
+INSERT INTO share VALUES (4, 4, 1, 'SHARE_TELEGRAM', 'SHARE_TELEGRAM_DESC', 'telegram.gif', 'https://t.me/share/url?url=');
+INSERT INTO share VALUES (5, 5, 1, 'SHARE_LINKEDIN', 'SHARE_LINKEDIN_DESC', 'linkedin.gif', 'https://www.linkedin.com/shareArticle?mini=true&url=');
+INSERT INTO share VALUES (6, 6, 1, 'SHARE_VKONTAKTE', 'SHARE_VKONTAKTE_DESC', 'vkontakte.gif', 'http://vk.com/share.php?url=');
 
 -- TAGS
 INSERT INTO text VALUES ('TAG_JS',      'es', 'TAG', 'Javascript', null);

+ 34 - 39
www/blog/index.php

@@ -67,7 +67,7 @@
         <div id='content'>
             <div id='content_row'>
                 <div class='content_cell' id='content_cell_main'>
-                    <div id='main_column' class='section'>
+                    <div id='post_list' class='section'>
                         <h3 class='section_title'><?=text($con, "BLOG_TITLE", $lang)?></h3>
 <?php
                             $q_blog = mysqli_query($con, "SELECT id, permalink, title, text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE visible = 1 ORDER BY dtime DESC;");
@@ -80,7 +80,7 @@
                                     <meta itemprop='articleBody text' content='<?=text($con, $r_blog["text"], $lang)?>'/>
                                     <meta itemprop='mainEntityOfPage' content='<?=$lserver?>'/>
                                     <h3 class='entry_title'>
-                                        <a itemprop='url' href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'><?=$r_blog["title"]?></a>
+                                        <a itemprop='url' href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'><?=text($con, $r_blog["title"], $lang)?></a>
                                     </h3>
 <?php
                                     $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r_blog[id] ORDER BY idx LIMIT 1;");
@@ -89,52 +89,28 @@
 ?>
                                         <div class='post_list_image_container'>
                                             <a href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'>
-                                                <meta itemprop='image' content='<?=$lserver?>/img/blog/view/<?=$r_image["image"]?>'/>
-                                                <img class='post_list_image alt='<?=$r_blog["title"]?>' src='<?=$lserver?>/img/blog/miniature/<?=$r_image["image"]?>'/>
+                                                <meta itemprop='image' content='<?=$lserver?>/img/blog/x4/<?=$r_image["image"]?>'/>
+                                                <img class='post_list_image' alt='<?=$r_blog["title"]?>' src='<?=$lserver?>/img/blog/x2/<?=$r_image["image"]?>'/>
                                             </a>
                                         </div>
 <?php
                                     }
 ?>
-                                    <p><?=cutText($r_blog["text"], 800, text($con, "BLOG_MORE", $lang), "$lserver/blog/$r_blog[permalink]/")?></p>
+                                    <p><?=cut_text(text($con, $r_blog["text"], $lang), 200, text($con, "BLOG_MORE", $lang), "$lserver/blog/$r_blog[permalink]/")?></p>
                                     <hr/>
-                                    <table class='post_footer'>
+                                    <table class='post_list_footer'>
                                         <tr>
+                                            <td class='date'>
+                                                <span class='date'><?=format_date($r_blog['dtime'], $lang, false)?></span>
+                                            </td>
 <?php
-                                            // Tags (if any), date, and comment counter
-                                            $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r_blog[id];");
-                                            if (mysqli_num_rows($q_tag) > 0){
-                                                $tag_string = "<span class='tags desktop'>" . text($con, "BLOG_TAGS", $lang);
-                                                $tag_raw = "";
-                                                while ($r_tag = mysqli_fetch_array($q_tag)){
-                                                    $tag_string = $tag_string . "<a href='$proto$http_host/blog/search/tag/$r_tag[tag]'> " . text($con, $r_tag["tag"], $lang) . "</a>, ";
-                                                    $tag_raw = $tag_raw . "$r_tag[tag],";
-                                                }
-                                                $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
-                                                $tag_string = $tag_string . "</span>";
-                                                $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
-?>
-                                                <meta itemprop='keywords' content='<?=$tag_raw?>'/>
-                                                <td>
-                                                    <span class='date'><?=format_date($r_blog["dtime"], $lang, false)?></span>
-                                                    &nbsp;&nbsp;&nbsp;<?=$tag_string?>
-                                                </td>
-<?php
-                                            }
-                                            else{
-?>
-                                                <td>
-                                                    <span class='date'><?=format_date($r_blog['dtime'], $lang, false)?></span>
-                                                </td>
-<?php
-                                            }
                                             #Comment counter
                                             if ($r_blog["comments"] == 1){
-                                                $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r_blog[id] AND visible = 1;");
+                                                $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r_blog[id] AND approved = 1;");
                                                 $r_comment = mysqli_fetch_array($q_comment);
 ?>
                                                 <meta itemprop='commentCount interationCount' content='<?=$r_comment["count"]?>'/>
-                                                <td class='r_comment'>
+                                                <td class='comment_counter'>
 <?php
                                                     if ($r_comment['count'] == 1){
 ?>
@@ -148,7 +124,7 @@
                                                     }
                                                     else{
 ?>
-                                                        <span class='comment_counter'>$<?=r_comment["count"]?> <?=text($con, "BLOG_COMMENTS_X", $lang)?></span>
+                                                        <span class='comment_counter'><?=$r_comment["count"]?> <?=text($con, "BLOG_COMMENTS_X", $lang)?></span>
 <?php
                                                     }
 ?>
@@ -157,7 +133,26 @@
                                             } // if ($r_blog["comments"] == 1)
 ?>
                                         </tr>
-                                    </table> <!-- .post_footer -->
+                                    </table> <!-- .post_list_footer -->
+<?php
+                                    // Tags
+                                    $q_tag = mysqli_query($con, "SELECT tag FROM post_tag WHERE post= $r_blog[id];");
+                                    if (mysqli_num_rows($q_tag) > 0){
+                                        $tag_string = "<span class='tags'>" . text($con, "BLOG_TAGS", $lang);
+                                        $tag_raw = "";
+                                        while ($r_tag = mysqli_fetch_array($q_tag)){
+                                            $tag_string = $tag_string . "<a href='$proto$http_host/blog/search/tag/$r_tag[tag]'> " . text($con, $r_tag["tag"], $lang) . "</a>, ";
+                                            $tag_raw = $tag_raw . "$r_tag[tag],";
+                                        }
+                                        $tag_string = substr($tag_string, 0, strlen($tag_string) - 2);
+                                        $tag_string = $tag_string . "</span>";
+                                        $tag_raw = substr($tag_raw, 0, strlen($tag_raw) - 1);
+?>
+                                        <meta itemprop='keywords' content='<?=$tag_raw?>'/>
+                                        <?=$tag_string?>
+<?php
+                                    }
+?>
                                 </div> <!-- .blog_entry -->
                                 </br>
 <?php
@@ -166,9 +161,9 @@
                     </div> <!-- #main_column -->
                 </div> <!-- #content_cell_main -->
                 <div class='content_cell'  id='content_cell_right'>
-                    <div class='section section_no_title' id='right_column'>
+                    <div class='section' id='right_column'>
+                        <h3 class='section_title'><?=text($con, "BLOG_SEARCH", $lang)?></h3>
                         <div class='entry'>
-                            <h4><?=text($con, "BLOG_SEARCH", $lang)?></h4>
                             <div id='search_panel_inputs'>
                                 <form action='#' onSubmit='event.preventDefault();launchSearch("<?=$lng["search_field_all"]?>");'>
                                     <input id='search_panel_input' class='search_element' type='text' name='query' placeholder='<?=text($con, "BLOG_SEARCH", $lang)?>'/>

+ 197 - 17
www/blog/post.php

@@ -8,8 +8,28 @@
     $server = $proto . $http_host;
     $lang = select_language();
     $lserver = $server . "/" . $lang;
-    $cur_section = "";
-    $cur_entry = "";
+
+    // Get post data
+    $permalink = mysqli_real_escape_string($con, $_GET["permalink"]);
+    $q_post = mysqli_query($con, "SELECT * FROM post WHERE permalink = '$permalink' AND visible = 1;");
+    if (mysqli_num_rows($q_post) == 0){
+        header("Location: $lserver/blog/");
+        exit(-1);
+    }
+    $r_post = mysqli_fetch_array($q_post);
+    $id = $r_post["id"];
+    $title = text($con, $r_post["title"], $lang);
+    $text = text($con, $r_post["text"], $lang);
+
+    $cur_section = "blog";
+    $cur_entry = $id;
+
+    // First image (if any)
+    $image = "";
+    $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id ORDER BY idx LIMIT 1");
+    if (mysqli_num_rows($q_image) > 0){
+        $image = mysqli_fetch_array($q_image)["image"];
+    }
 ?>
 <!DOCTYPE html>
 <html>
@@ -17,20 +37,20 @@
         <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
         <meta charset='utf-8'/>
         <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
-        <title>I&ntilde;igo Valentin</title>
+        <title><?=$title?> - I&ntilde;igo Valentin</title>
         <link rel='shortcut icon' href='<?=$lserver?>/img/logo/favicon.ico'/>
         <!-- CSS files -->
         <style>
 <?php
             include $doc_root . "css/ui.css";
-            include $doc_root . "css/home.css";
+            include $doc_root . "css/blog.css";
 ?>
         </style>
         <!-- CSS for mobile version -->
         <style media='(max-width : 990px)'>
 <?php
             include $doc_root . "css/m/ui.css";
-            include $doc_root . "css/m/home.css";
+            include $doc_root . "css/m/blog.css";
 ?>
         </style>
         <!-- Script files -->
@@ -40,31 +60,191 @@
 ?>
         </script>
         <!-- Meta tags -->
-        <link rel='canonical' href='<?=$lserver?>'/>
+        <link rel='canonical' href='<?=$lserver?>/blog/<?=$permalink?>'/>
         <link rel='author' href='<?=$lserver?>'/>
         <link rel='publisher' href='<?=$lserver?>'/>
-        <meta name='description' content=''/>
-        <meta property='og:title' content='I&ntilde;igo Valentin'/>
-        <meta property='og:url' content='<?=$lserver?>'/>
-        <meta property='og:description' content=''/>
-        <meta property='og:image' content=''/>
+        <meta name='description' content='<?=$text?>'/>
+        <meta property='og:title' content='<?=$title?> - I&ntilde;igo Valentin'/>
+        <meta property='og:url' content='<?=$lserver?>/blog/<?=$permalink?>'/>
+        <meta property='og:description' content='<?=$text?>'/>
+<?php
+        if (strlen($image) == 0){
+?>
+            <meta property="og:image" content="<?=$lserver?>/img/logo/x3/favicon.ico"/>
+<?php
+        }
+        else{
+?>
+            <meta property="og:image" content="<?=$lserver?>/img/blog/x3/<?=$image?>"/>
+<?php
+        }
+?>
         <meta property='og:site_name' content='I&ntilde;igo Valentin'/>
         <meta property='og:type' content='website'/>
         <meta property='og:locale' content='<?=$lang?>'/>
         <meta name='twitter:card' content='summary'/>
-        <meta name='twitter:title' content='I&ntilde;igo Valentin'/>
-        <meta name='twitter:description' content=''/>
-        <meta name='twitter:image' content=''/>
-        <meta name='twitter:url' content='<?=$lserver?>'/>
+        <meta name='twitter:title' content='<?=$title?> - I&ntilde;igo Valentin'/>
+        <meta name='twitter:description' content='<?=$text?>'/>
+<?php
+        if (strlen($image) == 0){
+?>
+            <meta property="twitter:image" content="<?=$lserver?>/img/logo/x3/favicon.ico"/>
+<?php
+        }
+        else{
+?>
+            <meta property="twitter:image" content="<?=$lserver?>/img/blog/x3/<?=$image?>"/>
+<?php
+        }
+?>        <meta name='twitter:url' content='<?=$lserver?>/blog/<?=$permalink?>'/>
         <meta name='robots' content='index follow'/>
     </head>
     <body>
 <?php
         include $doc_root . "header.php";
 ?>
-        <div id='content'>
+        <div class='section' id='post'>
+            <h3 class='section_title'><?=$title?></h3>
+            <div class='entry'>
+<?php
+                if (strlen($image) > 0){
+?>
+                    <img id='post_main_image' src='<?=$lserver?>/img/blog/x6/<?=$image?>' alt='<?=$title?>' title='<?=$title?>' />
+<?php
+                }
+?>
+                <?=$text?>
+<?php
+                $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $id ORDER BY idx OFFSET 1");
+                if (mysqli_num_rows($q_image) > 0){
+?>
+                    <div id='image_reel'>
+<?php
+                        while ($r_image = mysqli_fetch_array($q_image)){
+?>
+                            <img src='<?=$lserver?>/img/blog/x6/<?=$r_image["image"]?>' alt='<?=$title?>' title='<?=$title?>' />
+<?php
+                        }
+?>
+                    </div> <!-- #image_reel -->
+<?php
+                }
+?>
+                <hr/>
+                <!-- TODO: Tags and share -->
+<?php
+                    $q_share = mysqli_query($con, "SELECT id FROM share WHERE visible = 1 ORDER BY idx;");
+                    while ($r_share = mysqli_fetch_array($q_share)){
+?>
+                        <?=share_link($con, $r_share["id"], $lserver, "$server/blog/$permalink", $lang)?>
+<?php
+                    }
+?>
+                <hr/>
+<?php
+                #Comments
+                if ($r_post["comments"] == 1){
+                    $q_comment = mysqli_query($con, "SELECT id, post, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS cdate, DATE_FORMAT(dtime,'%b %d, %Y - %H:%i') AS dtime, user, username, text FROM post_comment WHERE post = $id;");
+                    $count = mysqli_num_rows($q_comment);
+                    if ($count == 1){
+?>
+                        <span class='comment_counter'>1 <?=text($con, "BLOG_COMMENTS_1", $lang)?></span>
+<?php
+                    }
+                    else if ($count == 0){
+?>
+                        <span class='comment_counter'><?=text($con, "BLOG_COMMENTS_0", $lang)?></span>
+<?php
+                    }
+                    else{
+?>
+                        <span class='comment_counter'><?=$count?> <?=text($con, "BLOG_COMMENTS_X", $lang)?></span>
+<?php
+                    }
+                    while ($r_comment = mysqli_fetch_array($q_comment)){
+                        $user = $r_comment["username"];
+                        $user_string = $user;
+                        if (strlen($user) == 0){
+                            $user = mysqli_fetch_array(mysqli_query($con, "SELECT concat(fname, concat(' ', lname)) AS name FROM user WHERE id = $r_comment[user];"))["name"];
+                            $user_string = "<span class='comment_user_registered'>$user</span>";
+                        }
+?>
+                        <div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_<?=$r_comment["id"]?>' class='comment'>
+                            <h4  class='comment_user'><?=$user_string?></h4>
+                            <meta itemprop='creator' content='<?=$user?>'>
+                            <span class='comment_date date'>
+                                <time itemprop='commentTime' datetime='<?=$r_comment["cdate"]?>'>
+                                <?=$r_comment["dtime"]?>
+                            </span>
+                            <p itemprop='commentText' class='comment_text'><?=$r_comment["text"]?></p>
+                        </div>
+<?php
+                    }
+                    //Comment form
+?>
+                    <div class='comment' id='comment_new'>
+                        <textarea id='new_comment_text' name='text' maxlength='1800' onfocus='showCommentIdentification();' placeholder='TR#Your comment...'></textarea>
+                        <div id='identification_form'>
+                            <br/>
+                            <input id='new_comment_user' name='user' maxlength='50' type='text' placeholder='TR#Your name'/>
+                            <input type='button' value='TR#Send comment'/>
+                        </div>
+                    </div>
+<?php
+                }
+                else{
+?>
+                    <h4>TR#Comments are closed in this post</h4>
+<?php
+                }
 
-        </div> <!-- #content -->
+?>
+                <hr/>
+<?php
+                // Previous / next
+                $q_prev = mysqli_query($con, "SELECT id, permalink, title FROM post WHERE id <> $id AND dtime <= '$r_post[dtime]' ORDER BY dtime DESC LIMIT 1;");
+                $q_next = mysqli_query($con, "SELECT id, permalink, title FROM post WHERE id <> $id AND dtime >= '$r_post[dtime]' ORDER BY dtime LIMIT 1;");
+                if (mysqli_num_rows($q_prev) > 0 || mysqli_num_rows($q_next) > 0){
+?>
+                    <table id='prev_next'>
+                        <tr>
+                            <td id='prev'>
+<?php
+                                if (mysqli_num_rows($q_prev) > 0){
+                                    $r_prev = mysqli_fetch_array($q_prev);
+?>
+                                    <a href='<?=$lserver?>/blog/<?=$r_prev["permalink"]?>'>
+                                        <span class='info'>Previous post:</span>
+                                        <br/>
+                                        <span class='title'><?=text($con, $r_prev["title"], $lang)?></span>
+                                    </a>
+<?php
+                                }
+?>
+                            </td>
+                            <td id='next'>
+<?php
+                                if (mysqli_num_rows($q_next) > 0){
+                                    $r_next = mysqli_fetch_array($q_next);
+?>
+                                    <a href='<?=$lserver?>/blog/<?=$r_next["permalink"]?>'>
+                                        <span class='info'>Next post:</span>
+                                        <br/>
+                                        <span class='title'><?=text($con, $r_next["title"], $lang)?></span>
+                                    </a>
+<?php
+                                }
+?>
+                            </td>
+                        </tr>
+                    </table>
+<?php
+                }
+?>
+                <hr/>
+                <!-- TODO: Related posts -->
+            </div> <!-- .entry -->
+        </div> <!-- .section -->
 <?php
         include $doc_root . "footer.php";
         stats($con, $cur_section, $cur_entry);

+ 67 - 37
www/css/blog.css

@@ -1,62 +1,92 @@
-/* Common elements */
-span.version_type{
-    padding: 0.05em;
-    border 0.1em solid #444444;
-    border-radius: 0.2em;
+/* Blog main page */
+
+div#post_list img.post_list_image{
+    float: left;
+    background-color: #ffffff;
+    border: 0.1em solid #003300;
+    border-radius: 0.3em;
+    margin: 0 0.7em 0.7em 0.7em;
+    max-width: 5em;
+    max-height: 3em;
 }
 
+div#post_list table.post_list_footer{
+    font-size: 80%;
+    width: 100%;
+}
 
-/* Projects main page */
+div#post_list table.post_list_footer td.comment_counter{
+    font-style: italic;
+    text-align: right;
+}
 
+div#post_list span.tags{
+    font-size: 80%;
+    font-style: italic;
+}
 
-/* Project view page */
+/* Post view page */
 
-div#content{
-    display: table;
+div#post{
+    width: 90%;
+    max-width: 80em;
+    margin: 1em auto 1em auto;
 }
 
-div#content-row{
-    display: table-row;
+div#post img#post_main_image{
+    display: block;
+    max-height: 11em;
+    margin: 0.5em auto 1em auto;
+    border: 0.1em solid #003400;
+    border-radius: 0.5em;
+    background-color: #ffffff;
 }
 
-div.content_cell{
-    display: table-cell;
-    padding: 1em;
-    vertical-align: top;
+div#post div#image_reel{
+    overflow-x: scroll;
+    border: 0.1em solid #003400;
+    border-radius: 0.3em;
+    height: 7em;
+    background-color: #334433;
+    padding: 0.5em;
 }
 
-div#content_cell_main{
-    width: 80%;
+div#project_edit div#image_reel img{
+    vertical-align: middle;
+    max-height: 5em;
+    max-width: 7em;
+    border: 0.2em solid #003400;
+    border-radius: 0.1em;
+    margin: 0.5em;
+    background-color: #ffffff;
 }
 
-div#content_cell_right{
-    width: 20%;
+table#prev_next{
+    width: 90%;
+    max-width: 60em;
+    border-collapse: collapse;
+    margin: 1em auto 1em auto;
 }
 
-div#main_column div.iframe_container{
-    width: 100%;
-    text-align: center;
+table#prev_next td{
+    width: 50%;
+    text-align: center
+    padding: 0.5em;
 }
 
-div#main_column iframe.project_embed{
-    background-color: #ffffff;
-    border-radius: 0.8em;
-    border: 0.1em solid #110022;
-    max-width: 90%;
-    max-height: 70em;
+table#prev_next td#prev{
+    border-right: 0.03em solid #00440088;
+    text-align: right;
 }
 
-div#right_column{
-    transition: all .3s ease-in-out;
+table#prev_next td#next{
+    border-left: 0.03em solid #00440088;
 }
 
-div#right_column div.url{
-    vertical-align: middle;
+table#prev_next td span.info{
+    font-size: 80%;
 }
 
-div#right_column div.url img{
-    width: 2em;
-    height: 2em;
-    vertical-align: middle;
+table#prev_next td span.title{
+    font-weight: bold;
 }
-

+ 22 - 0
www/css/home.css

@@ -28,3 +28,25 @@ div#content div#content_row div#content_cell_profile{
 div#content div#content_row div#content_cell_content{
     width: 70%;
 }
+
+
+/* Blog section */
+div#blog_section img.post_list_image{
+    float: left;
+    background-color: #ffffff;
+    border: 0.1em solid #003300;
+    border-radius: 0.3em;
+    margin: 0 0.5em 0.5em 0.5em;
+    max-width: 5em;
+    max-height: 3em;
+}
+
+div#blog_section table.post_list_footer{
+    font-size: 80%;
+    width: 100%;
+}
+
+div#blog_section table.post_list_footer td.comment_counter{
+    font-style: italic;
+    text-align: right;
+}

+ 5 - 0
www/css/m/ui.css

@@ -57,3 +57,8 @@ div#footer a.lang img:hover{
 div.section{
     margin: 1em;
 }
+
+div.section div.entry_list{
+    background-color: #efffef;
+    border: 0.1em solid #aaffaaff;
+}

+ 26 - 89
www/css/ui.css

@@ -472,20 +472,25 @@ div#identification_form{
 
 /* Contain a comment, with the details and the text */
 div.comment{
-    background-color: #cccccc;
-    border: 0.143em solid #777777;
-    border-radius: 0.314em;
+    background-color: #efffef;
+    border: 0.1em solid #aaffaa;
+    border-radius: 0.3em;
     padding: 0.5em;
-    margin: 0.714em 0.625em 0.714em 0.625em;
-    box-shadow: 0 0 0.750em #444444;
+    margin: 0.5em;
 }
 
 /* User who posted the coment */
-h4.comment_user{
+div.comment h4.comment_user{
     margin-top: 0.417em;
     margin-bottom: 0;
 }
 
+div.comment h4.comment_user span.comment_user_registered{
+    font-weight: bold;
+    font-size: 110%;
+    color: #005500;
+}
+
 /* Style for the comment's images */
 img.comment_image{
     border: 0.077em solid black;
@@ -554,92 +559,24 @@ img#new_comment_image_preview{
 }
 
 
-
-/**********************************
- * Styles for the pager, present  *
- * in blog, tutorials, etc        *
- **********************************/
-
-/* A table containing the pager */
-table#pager{
-    margin-left: auto;
-    margin-right: auto;
-    border-spacing: 0.625em
-}
-
-/* Each cell in the pager */
-table#pager td{
-    font-weight: bold;
-    color: #cccccc;
-    background-color: #bbbbbb;
-    border: 0.077em solid #666666;
-    border-radius: 0.231em;
-    padding: 0.5em 0.625em 0.5em 0.625em;
-    text-shadow: 0 0 0.75em #000000;
-}
-
-/* The current page */
-table#pager td.pager_current{
-    background-color: #666666;
-    border: 0.077em solid #444444;
-}
-
-/* Dummy td that contains "..." */
-table#pager td.pager_ellipse{
-    background-color: initial;
-    border: initial;
-}
-
-
-
-/**********************************
- * Styles for social sharing icon *
- **********************************/
-
-/* Icons for social media */
-img.share_icon{
-    width: 1.875em;
-    vertical-align: middle;
-}
-
-
-
 /**********************************
- * Styles for downloads           *
+ * Styles for the social buttons. *
  **********************************/
 
-/* Dummy span for download count */
-span#span_download{
-    display: none;
-}
-
-/* Hidden div to confirm downloading */
-div.license{
-    box-shadow: 0 0 1.2em rgba(120, 120, 120, 1);
-    display: none;
-    position: fixed;
-    top: 30%;
-    left: 25%;
-    width: 40%;
-    opacity: 0;
-    z-index: 1001;
-    padding: 0.625em;
-    background-color: #333333;
-    border: 0.150em solid #111111;
-    border-radius: 1.250em;
+a.share img.share{
+    display: inline-block;
+    vertical-align: top;
+    overflow: hidden;
+    width: 2em;
+    height: 2em;
+    border: 0.1em solid #003300;
+    border-radius: 2em;
+    box-shadow: 0 0 0.3em #005500;
+    margin: 0.2em;
+    transition: all .3s ease-in-out;
 }
 
-/* div to dimm the screen */
-#screen_cover{
-    position: fixed;
-    top: 0;
-    left: 0;
-    background-color: black;
-    display: none;
-    width: 100%;
-    height: 100%;
-    opacity: 0;
-    transition: all .9s ease-in-out;
-    z-index: 1000;
+a.share img.share:hover{
+    box-shadow: 0 0 0.7em #005500;
+    border-radius: 0.7em;
 }
-

+ 29 - 0
www/functions.php

@@ -228,6 +228,35 @@
         return $str;
     }
 
+    /*****************************************************
+     * Generates a "Share" link for a network.           *
+     *                                                   *
+     * @params:                                          *
+     *    con (Mysql connection): Connection handler.    *
+     *    network (int): Social network ID.              *
+     *    server: (string): Server name. Can be empty.   *
+     *    url: (string): URL to be shared.               *
+     *    lang: (string): Language code (two letters).   *
+     * @return: (string): URL-valid string.              *
+     *****************************************************/
+    function share_link($con, $network, $server, $url, $lang){
+        if (strlen($url) == 0){
+            return "";
+        }
+        $out = "<a class='share' target='_blank' ";
+        $q_network = mysqli_query($con, "SELECT url, icon, title, text FROM share WHERE visible = 1 AND id = $network;");
+        if (mysqli_num_rows($q_network) == 0){
+            return "";
+        }
+        else{
+            $r_network = mysqli_fetch_array($q_network);
+            $out = $out . "href='" . $r_network["url"] . htmlspecialchars($url) . "' title='" . text($con, $r_network["text"], $lang) . "'>";
+            $out = $out . "<img class='share' src='" . $server . "/img/social/x1/" . $r_network["icon"] . "' alt='" . text($con, $r_network["text"], $lang) . "' title='" . text($con, $r_network["text"], $lang) . "' />";
+            $out = $out . "</a>";
+            return $out;
+        }
+    }
+
 
     /*****************************************************
      * Retrieves a text fragment from the database.      *

BIN
www/img/social/github.png


+ 0 - 0
www/img/social/googleplus.gif → www/img/social/google.gif


BIN
www/img/social/telegram.gif


BIN
www/img/social/vkontakte.gif


BIN
www/img/social/x1/github.png


BIN
www/img/social/x1/google.gif


BIN
www/img/social/x1/telegram.gif


BIN
www/img/social/x1/vkontakte.gif


BIN
www/img/social/x2/github.png


BIN
www/img/social/x2/google.gif


BIN
www/img/social/x2/telegram.gif


BIN
www/img/social/x2/vkontakte.gif


BIN
www/img/social/x3/github.png


BIN
www/img/social/x3/google.gif


BIN
www/img/social/x3/telegram.gif


BIN
www/img/social/x3/vkontakte.gif


BIN
www/img/social/x4/github.png


BIN
www/img/social/x4/google.gif


BIN
www/img/social/x4/telegram.gif


BIN
www/img/social/x4/vkontakte.gif


BIN
www/img/social/x5/github.png


BIN
www/img/social/x5/google.gif


BIN
www/img/social/x5/telegram.gif


BIN
www/img/social/x5/vkontakte.gif


BIN
www/img/social/x6/github.png


BIN
www/img/social/x6/google.gif


BIN
www/img/social/x6/telegram.gif


BIN
www/img/social/x6/vkontakte.gif


+ 61 - 21
www/index.php

@@ -107,35 +107,75 @@
                         }
 ?>
                     </div> <!-- .section -->
-                    <div class='section'>
+                    <div class='section' id='blog_section'>
                         <h3 class='section_title'>TR#Ultimos posts</h3>
 <?php
-                        $q_blog = mysqli_query($con, "SELECT * FROM post WHERE visible = 1 ORDER BY dtime DESC LIMIT 2;");
-                        while ($r_blog = mysqli_fetch_array($q_blog)){
-                            $q_image = mysqli_query($con, "SELECT * FROM post_image WHERE post = $r_blog[id] ORDER BY id LIMIT 1;");
+                        $q_blog = mysqli_query($con, "SELECT id, permalink, title, text, DATE_FORMAT(dtime, '%Y-%m-%dT%T') AS isodate, dtime, comments FROM post WHERE visible = 1 ORDER BY dtime DESC;");
+                        while($r_blog = mysqli_fetch_array($q_blog)){
 ?>
-                            <a href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'>
-                                <div class='entry entr_list blog_row'>
-                                    <table>
-                                        <tr>
+                            <div itemscope itemtype='http://schema.org/BlogPosting' class='entry entry_list blog_entry'>
+                                <meta itemprop='inLanguage' content='<?=$lang?>'/>
+                                <meta itemprop='datePublished dateModified' content='<?=$r_blog["isodate"]?>'/>
+                                <meta itemprop='headline name' content='<?=text($con, $r_blog["title"], $lang)?>'/>
+                                <meta itemprop='articleBody text' content='<?=text($con, $r_blog["text"], $lang)?>'/>
+                                <meta itemprop='mainEntityOfPage' content='<?=$lserver?>'/>
+                                <h3 class='entry_title'>
+                                    <a itemprop='url' href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'><?=text($con, $r_blog["title"], $lang)?></a>
+                                </h3>
 <?php
-                                            if (mysqli_num_rows($q_image) > 0){
-                                                $r_image = mysqli_fetch_array($q_image);
+                                $q_image = mysqli_query($con, "SELECT image FROM post_image WHERE post = $r_blog[id] ORDER BY idx LIMIT 1;");
+                                if (mysqli_num_rows($q_image) > 0){
+                                    $r_image = mysqli_fetch_array($q_image);
 ?>
-                                                <td>
-                                                    <img alt='<?=text($con, $r_blog["title"], $lang)?>' title='<?=text($con, $r_blog["title"], $lang)?>' src='<?=$lserver?>/img/blog/x2/<?=$r_image["image"]?>'/>
-                                                </td>
+                                    <div class='post_list_image_container'>
+                                        <a href='<?=$lserver?>/blog/<?=$r_blog["permalink"]?>'>
+                                            <meta itemprop='image' content='<?=$lserver?>/img/blog/x4/<?=$r_image["image"]?>'/>
+                                            <img class='post_list_image' alt='<?=$r_blog["title"]?>' src='<?=$lserver?>/img/blog/x2/<?=$r_image["image"]?>'/>
+                                        </a>
+                                    </div>
 <?php
-                                            }
+                                }
+?>
+                                <p><?=cut_text(text($con, $r_blog["text"], $lang), 150, text($con, "BLOG_MORE", $lang), "$lserver/blog/$r_blog[permalink]/")?></p>
+                                <hr/>
+                                <table class='post_list_footer'>
+                                    <tr>
+                                        <td class='date'>
+                                            <span class='date'><?=format_date($r_blog['dtime'], $lang, false)?></span>
+                                        </td>
+<?php
+                                        #Comment counter
+                                        if ($r_blog["comments"] == 1){
+                                            $q_comment = mysqli_query($con, "SELECT count(id) AS count FROM post_comment WHERE post = $r_blog[id] AND approved = 1;");
+                                            $r_comment = mysqli_fetch_array($q_comment);
+?>
+                                            <meta itemprop='commentCount interationCount' content='<?=$r_comment["count"]?>'/>
+                                            <td class='comment_counter'>
+<?php
+                                                if ($r_comment['count'] == 1){
+?>
+                                                    <span class='comment_counter'>1 <?=text($con, "BLOG_COMMENTS_1", $lang)?></span>
+<?php
+                                                }
+                                                else if ($r_comment['count'] == 0){
+?>
+                                                    <span class='comment_counter'><?=text($con, "BLOG_COMMENTS_0", $lang)?></span>
+<?php
+                                                }
+                                                else{
+?>
+                                                    <span class='comment_counter'><?=$r_comment["count"]?> <?=text($con, "BLOG_COMMENTS_X", $lang)?></span>
+<?php
+                                                }
 ?>
-                                            <td>
-                                                <h4><?=text($con, $r_blog["title"], $lang)?></h4>
-                                                <?=cut_text(text($con, $r_project["header"], $lang), 165, "TR#Leer mas", $lserver . "/blog/" . $r_blog["permalink"])?>
                                             </td>
-                                        </tr>
-                                    </table>
-                                </div> <!-- .entry -->
-                            </a>
+<?php
+                                        } // if ($r_blog["comments"] == 1)
+?>
+                                    </tr>
+                                </table> <!-- .post_list_footer -->
+                            </div> <!-- .blog_entry -->
+                            </br>
 <?php
                         }
 ?>

+ 2 - 2
www/project/project.php

@@ -73,7 +73,7 @@
         <meta property="og:url" content="<?=$lserver?>/project/<?=$r_project["permalink"]?>"/>
         <meta property="og:description" content="<?=$summary?>"/>
 <?php
-        if (strlen($r_project["logo"]) > 0){
+        if (strlen($r_project["logo"]) == 0){
 ?>
             <meta property="og:image" content="<?=$lserver?>/img/logo/x3/favicon.ico"/>
 <?php
@@ -91,7 +91,7 @@
         <meta name="twitter:title" content="<?=$title?> - I&ntilde;igo Valentin"/>
         <meta name="twitter:description" content="<?=$summary?>"/>
 <?php
-        if (strlen($r_project["logo"]) > 0){
+        if (strlen($r_project["logo"]) == 0){
 ?>
             <meta name="twitter:image" content="<?=$lserver?>/img/logo/x3/favicon.ico"/>
 <?php