From f4e431da27f63b70b0263adc2a80c16dcfcd339b Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 12 Feb 2015 18:24:47 +1300 Subject: [PATCH] Update theme --- code/model/Blog.php | 24 ++++---- code/model/BlogPost.php | 2 +- css/blog.css | 43 +++++++++++++++ templates/Includes/BlogSideBar.ss | 3 + templates/Includes/EntryMeta.ss | 17 ++++++ templates/Layout/Blog.ss | 64 ++++++++++++++++++++++ templates/Layout/BlogPost.ss | 17 ++++++ templates/WidgetHolder.ss | 4 ++ templates/widgets/BlogArchiveWidget.ss | 7 ++- templates/widgets/BlogCategoriesWidget.ss | 11 +++- templates/widgets/BlogRecentPostsWidget.ss | 11 +++- templates/widgets/BlogTagsWidget.ss | 11 +++- 12 files changed, 191 insertions(+), 23 deletions(-) create mode 100755 css/blog.css create mode 100644 templates/Includes/BlogSideBar.ss create mode 100644 templates/Includes/EntryMeta.ss create mode 100644 templates/Layout/Blog.ss create mode 100644 templates/Layout/BlogPost.ss create mode 100644 templates/WidgetHolder.ss mode change 100755 => 100644 templates/widgets/BlogArchiveWidget.ss mode change 100755 => 100644 templates/widgets/BlogCategoriesWidget.ss mode change 100755 => 100644 templates/widgets/BlogRecentPostsWidget.ss mode change 100755 => 100644 templates/widgets/BlogTagsWidget.ss diff --git a/code/model/Blog.php b/code/model/Blog.php index 7b98869..9e75111 100644 --- a/code/model/Blog.php +++ b/code/model/Blog.php @@ -266,21 +266,21 @@ class Blog_Controller extends Page_Controller { /** - * Returns a list of paginated blog posts based on the blogPost dataList + * If pagination is enabled, this returns a list of paginated blog posts + * based on the blogPost dataList. Otherwise a simple list will be returned. * - * @return PaginatedList + * @return SS_List **/ public function PaginatedList() { - $posts = new PaginatedList($this->blogPosts); - - // If pagination is set to '0' then no pagination will be shown. - if($this->PostsPerPage > 0) $posts->setPageLength($this->PostsPerPage); - else $posts->setPageLength($this->getBlogPosts()->count()); - - $start = $this->request->getVar($posts->getPaginationGetVar()); - $posts->setPageStart($start); - - return $posts; + // Set page size + if($this->PostsPerPage > 0) { + $posts = new PaginatedList($this->blogPosts, $this->request); + $posts->setPageLength($this->PostsPerPage); + return $posts; + } else { + // If there is no pagination, return the unpaginated list + return $this->blogPosts; + } } diff --git a/code/model/BlogPost.php b/code/model/BlogPost.php index 4f9422a..fd14241 100644 --- a/code/model/BlogPost.php +++ b/code/model/BlogPost.php @@ -75,7 +75,7 @@ class BlogPost extends Page { // We're going to add the url segment to sidebar so we're making it a little lighter $urlSegment = $fields->dataFieldByName('URLSegment'); - $urlSegment->setURLPrefix('/' . Director::makeRelative($self->Parent()->Link())); + $urlSegment->setURLPrefix($self->Parent()->RelativeLink()); // Remove the MenuTitle and URLSegment from the main tab $fields->removeFieldsFromTab('Root.Main', array( diff --git a/css/blog.css b/css/blog.css new file mode 100755 index 0000000..23be840 --- /dev/null +++ b/css/blog.css @@ -0,0 +1,43 @@ +.blog-sidebar { + margin-top: 12px; +} + +.blog-sidebar .secondary { + margin-bottom: 35px; +} + +#Form_CommentsForm + h4 { + clear: both; + padding-top: 35px; + display: block; +} + +.typography ul.comments-list { + margin: 0; +} + +.typography ul.comments-list > li { + list-style: none; + border-bottom: 1px solid #e5e5e5; + padding: 10px 0; +} + +.typography ul.comments-list > li .action-links { + margin: 0; +} + +.typography ul.comments-list > li .action-links li { + list-style: none; + margin-right: 10px; +} + +.commenting-rss-feed { + clear: both; +} + +@media only screen and (max-width: 640px) { + .blog-sidebar { + width: 100%; /* sidenav is now shown above the page content */ + margin-bottom: 30px; + } +} \ No newline at end of file diff --git a/templates/Includes/BlogSideBar.ss b/templates/Includes/BlogSideBar.ss new file mode 100644 index 0000000..97d3a0b --- /dev/null +++ b/templates/Includes/BlogSideBar.ss @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/templates/Includes/EntryMeta.ss b/templates/Includes/EntryMeta.ss new file mode 100644 index 0000000..474fc4f --- /dev/null +++ b/templates/Includes/EntryMeta.ss @@ -0,0 +1,17 @@ +

+ This entry was + <% if Categories %> + posted in + <% loop Categories %> + $Title<% if not Last %>, <% else_if Up.Tags %>, <% else %> and<% end_if %> + <% end_loop %> + <% end_if %> + <% if Tags %> + tagged + <% loop Tags %> + $Title<% if not Last %>, <% end_if %> + <% end_loop %> + and + <% end_if %> + posted on $PublishDate.format("F j, Y") +

\ No newline at end of file diff --git a/templates/Layout/Blog.ss b/templates/Layout/Blog.ss new file mode 100644 index 0000000..e190eaa --- /dev/null +++ b/templates/Layout/Blog.ss @@ -0,0 +1,64 @@ +<% require css(themes/simple_blog/css/blog.css) %> + +<% include BlogSideBar %> +
+

+ <% if ArchiveYear %> + Archive: <% if ArchiveDay %>$ArchiveDate.Nice<% else_if ArchiveMonth %>$ArchiveDate.format("F, Y")<% else %>$ArchiveDate.format(Y)<% end_if %> + <% else_if CurrentTag %> + Tag: $CurrentTag.Title + <% else_if CurrentCategory %> + Category: $CurrentCategory.Title + <% else %> + $Title + <% end_if %> +

+ + <% if PaginatedList %> + + <% else %> +

No Posts

+ <% end_if %> + + <% if PaginatedList.MoreThanOnePage %> +
+ +

Page $PaginatedList.CurrentPage of $PaginatedList.TotalPages

+
+ <% end_if %> +
diff --git a/templates/Layout/BlogPost.ss b/templates/Layout/BlogPost.ss new file mode 100644 index 0000000..69f10d4 --- /dev/null +++ b/templates/Layout/BlogPost.ss @@ -0,0 +1,17 @@ +<% require css(themes/simple_blog/css/blog.css) %> + +<% include BlogSideBar %> +
+
+

$Title

+ + <% if FeaturedImage %> + $FeaturedImage.Title + <% end_if %> + +
$Content
+ + <% include EntryMeta %> +
+ $PageComments +
\ No newline at end of file diff --git a/templates/WidgetHolder.ss b/templates/WidgetHolder.ss new file mode 100644 index 0000000..f73142e --- /dev/null +++ b/templates/WidgetHolder.ss @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/templates/widgets/BlogArchiveWidget.ss b/templates/widgets/BlogArchiveWidget.ss old mode 100755 new mode 100644 index 5a30f2b..00dacde --- a/templates/widgets/BlogArchiveWidget.ss +++ b/templates/widgets/BlogArchiveWidget.ss @@ -1,7 +1,12 @@ <% if Archive %> <% end_if %> \ No newline at end of file diff --git a/templates/widgets/BlogCategoriesWidget.ss b/templates/widgets/BlogCategoriesWidget.ss old mode 100755 new mode 100644 index 395a87c..558f09f --- a/templates/widgets/BlogCategoriesWidget.ss +++ b/templates/widgets/BlogCategoriesWidget.ss @@ -1,7 +1,12 @@ -<% if Categories %> +<% if $Categories %> <% end_if %> \ No newline at end of file diff --git a/templates/widgets/BlogRecentPostsWidget.ss b/templates/widgets/BlogRecentPostsWidget.ss old mode 100755 new mode 100644 index c1905e4..0dfc2a2 --- a/templates/widgets/BlogRecentPostsWidget.ss +++ b/templates/widgets/BlogRecentPostsWidget.ss @@ -1,7 +1,12 @@ -<% if Posts %> +<% if $Posts %> <% end_if %> \ No newline at end of file diff --git a/templates/widgets/BlogTagsWidget.ss b/templates/widgets/BlogTagsWidget.ss old mode 100755 new mode 100644 index faa10a0..4fcb1dc --- a/templates/widgets/BlogTagsWidget.ss +++ b/templates/widgets/BlogTagsWidget.ss @@ -1,7 +1,12 @@ -<% if Tags %> +<% if $Tags %> <% end_if %> \ No newline at end of file