]> _ Git - fluidbook-v3.git/commitdiff
WIP #3641 @6
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 May 2020 18:38:17 +0000 (18:38 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 27 May 2020 18:38:17 +0000 (18:38 +0000)
framework/application/controllers/BlogpostController.php
framework/application/forms/CMS/Blog.php
framework/application/forms/CMS/Element/AuthorSelectList.php [new file with mode: 0644]
framework/application/forms/CMS/Element/Authors.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Authors.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Blog/Post.php
framework/application/models/Author.php [new file with mode: 0644]
framework/application/models/Blog.php
framework/application/views/helpers/BlogBody.php
less/610-blog.less

index 33c34a48b174576af49f252ba025e35a4d824ad7..716788339a686485a0e3ef529325044129cce897 100644 (file)
@@ -33,6 +33,7 @@ class BlogpostController extends CubeIT_Controller_PageController {
         $post = $post->unserialize();
 
         $this->view->post = $post->unserialize();
+        $this->view->author = $post->getAuthorModel()->unserialize();
         $this->view->headTitle($post->getTitle(), 'SET');
     }
 
index d1f503e631eba810a81bcc682859144e92475740..f80ec670e6973e3ad3130f39ef04af742302539b 100644 (file)
@@ -10,5 +10,9 @@ class Fluidbook_Form_CMS_Blog extends Fluidbook_Form_CMS_Base {
                $blog->setLabel('Blog Posts');\r
                $this->addElement($blog);\r
 \r
+               $authors = new Fluidbook_Form_CMS_Element_Authors('authors');\r
+               $authors->setLabel('Authors');\r
+               $this->addElement($authors);\r
+\r
        }\r
 }\r
diff --git a/framework/application/forms/CMS/Element/AuthorSelectList.php b/framework/application/forms/CMS/Element/AuthorSelectList.php
new file mode 100644 (file)
index 0000000..512b3b7
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+class Fluidbook_Form_CMS_Element_AuthorSelectList extends CubeIT_Form_Element_SelectList {
+
+    public function init() {
+        parent::init();
+        $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Authors());
+    }
+
+}
diff --git a/framework/application/forms/CMS/Element/Authors.php b/framework/application/forms/CMS/Element/Authors.php
new file mode 100644 (file)
index 0000000..b83c477
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+class Fluidbook_Form_CMS_Element_Authors extends CubeIT_Form_Element_List {
+    public function init() {
+        parent::init();
+
+        $this->setBaseForm(new Fluidbook_Form_CMS_Sub_Authors());
+        $this->clearDecorators();
+    }
+
+}
diff --git a/framework/application/forms/CMS/Sub/Authors.php b/framework/application/forms/CMS/Sub/Authors.php
new file mode 100644 (file)
index 0000000..2365129
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+class Fluidbook_Form_CMS_Sub_Authors extends CubeIT_Form_List_Model
+{
+
+    public function init() {
+        parent::init();
+
+        $compact_translations = false;
+
+        $id = new CubeIT_Form_Element_Id();
+        $this->addElement($id);
+
+        $photo = new CubeIT_Form_Element_File_Image('photo');
+        $photo->setLabel(__('Photo'));
+        $photo->setMaxItems(1);
+        $this->addElement($photo);
+
+        $name = new CubeIT_Form_Element_Text('name');
+        $name->setLabel(__('Author Name'));
+        $this->addElement($name);
+
+        $email = new CubeIT_Form_Element_Text('email');
+        $email->setLabel(__('E-mail address'));
+        $this->addElement($email);
+
+        $bio = new CubeIT_Form_Element_Markitup('bio');
+        $bio->setLabel(__('Author Bio'));
+        $this->addElementLocalized($bio, $compact_translations);
+
+        $this->setListTitle(__('Authors'));
+        $this->setNewTitle(__('New Author'));
+        $this->setEditTitle(__('Editing author « $name »'));
+        $this->setModel('Fluidbook_Model_Author');
+        $this->setTitleColumn('name');
+        $this->setAdditionnalColumns(['email']);
+
+    }
+}
index b86e46d7ad3f7ae210649c89b4f1f7d867345171..9c33fbdcb7b7dec27ad279a8b16a91bd1e87e5c9 100644 (file)
@@ -22,6 +22,10 @@ class Fluidbook_Form_CMS_Sub_Blog_Post extends CubeIT_Form_List_Model
         $date->setLabel(__('Publish Date'));
         $this->addElement($date);
 
+        $author = new Fluidbook_Form_CMS_Element_AuthorSelectList('author_id');
+        $author->setLabel('Author');
+        $this->addElement($author);
+
         $title = new CubeIT_Form_Element_Text('title');
         $title->setLabel(__('Post Title'));
         $this->addElementLocalized($title, $compact_translations);
diff --git a/framework/application/models/Author.php b/framework/application/models/Author.php
new file mode 100644 (file)
index 0000000..1352b18
--- /dev/null
@@ -0,0 +1,21 @@
+<?php\r
+\r
+class Fluidbook_Model_Author extends CubeIT_Model_Data_Table\r
+{\r
+    protected static $_table = 'authors';\r
+\r
+    protected $name;\r
+    protected $email;\r
+    protected $bio;\r
+    protected $photo;\r
+\r
+    public static function getSchema($schema) {\r
+        $table = parent::getSchema($schema);\r
+        $table->addColumn('name', 'string', ['length' => 255]);\r
+        $table->addColumn('email', 'string', ['length' => 255]);\r
+        $table->addColumn('bio', 'text');\r
+        $table->addColumn('photo', 'string', ['length' => 255]);\r
+        return $table;\r
+    }\r
+\r
+}\r
index 746128f9f1bd388648b68033dd3173a20b8031f1..2ad82a9e2b9750bd371c8f9de3873d71881efcfe 100644 (file)
@@ -34,4 +34,13 @@ class Fluidbook_Model_Blog extends CubeIT_Model_Data_Table
         return $table;\r
     }\r
 \r
+    public function getAuthorModel() {\r
+        $authorID = $this->getAuthorId();\r
+        if ($authorID == 0)\r
+            return null;\r
+\r
+        $author = Fluidbook_Model_Author::factory()->where('id = ?', $authorID)->find();\r
+        return reset($author);\r
+    }\r
+\r
 }\r
index b58f30c6b69a34fb0eaa4ec40a449bb883250832..6dcdb087188b0c19794702926e6de66f3c38c604 100644 (file)
@@ -24,6 +24,20 @@ class Fluidbook_View_Helper_BlogBody extends CubeIT_View_Helper_Abstract {
             $res .= '</div>'; // .block-$content->content_type
         }
 
+        // Author details
+        $photo = $this->imageProcess()->imageProcessGetUrl($this->author->getPhoto(), null, 120, 120);
+        $res .= '<div class="blog-author" itemscope itemtype="http://schema.org/Person">';
+        $res .= '<div class="blog-author-photo" itemprop="image" style="background-image:url('. $photo .');"></div>';
+        $res .= '<div class="blog-author-details">';
+        $res .= '<h3 class="blog-author-name" itemprop="name">'. $this->author->getName() .'</h3>';
+        $res .= '<p class="blog-author-bio" itemprop="jobTitle">'. $this->author->getBio() .'</p>';
+        $res .= $this->linkEmail($this->author->getEmail(), null, ['class' => 'blog-author-email', 'itemprop' => 'email']);
+        $res .= '</div>'; // .blog-author-details
+//        $res .= '<pre>';
+//        $res .= print_r($this->author, true);
+//        $res .= '</pre>';
+        $res .= '</div>'; // .blog-author
+
         $res .= '</div>'; // .blog-post-body
         $res .= '</div>'; // .content-wrapper
 
index 43e1f2c36a636ecdb391dd2ab0645d372bce789c..2d7f6f24e3acf68868b7934328cc4eaae55e1c39 100644 (file)
@@ -44,6 +44,7 @@
 
     &:after {
       background-color: currentColor !important;
+      bottom: 0.7em !important;
     }
 
     a {
@@ -59,6 +60,7 @@
   &-excerpt {
     font-size: 15px;
     line-height: 1.7;
+    max-width: 550px;
   }
 
   .picture {
 
 
 .blog-post-body {
-  max-width: 1008px;
   margin: 0 auto;
   font-size: 24px;
   line-height: 1.67;
+  max-width: 1008px;
+  width: 100%;
 
   > * + * {
     margin-top: 1.5em;
   }
 
-  img {
-    max-width: 100%;
-    height: auto;
+  .image {
+
+    // Super-sized images that break out of the content column when
+    // there is space but never go beyond 90% width. On smaller screens,
+    // they scale down normally within the content column...
+    &-xl {
+      position: relative;
+      left: 50%;
+      transform: translateX(-50%);
+      width: 1512px; // 90% of 1680px
+      max-width: 90vw;
+    }
+
+    img {
+      display: block;
+      max-width: 100%;
+      height: auto;
+      margin: 0 auto;
+    }
+
+    figcaption {
+      font-size: 15px;
+      text-align: center;
+      margin-top: 1.5em;
+    }
+  }
+
+}
+
+.blog-author {
+  display: flex;
+  align-items: center;
+  background-color: #f3f3f3;
+  margin-top: 50px;
+  padding: 1.5em;
+  font-size: 15px;
+
+  &-photo {
+    width: 120px;
+    height: 120px;
+    background-size: cover;
+    background-position: center;
+    background-repeat: no-repeat;
+    border-radius: 50%;
+    margin-right: 1.5em;
   }
 
+  &-name {
+    font-family: @heading-font;
+    font-size: 30px;
+  }
 }