From 000ab373552f5cda51dd501525ba4e579f9243d0 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 28 Jul 2016 09:08:37 -0400 Subject: reorganize post views --- data/themes/blank/templates/blog-list-item.html | 8 ++++++++ data/themes/blank/templates/blog-list.html | 17 +++++++++++++++++ data/themes/blank/templates/page.html | 15 --------------- data/themes/blank/templates/post-blog.html | 15 +++++++++++++++ data/themes/blank/templates/post-page.html | 15 +++++++++++++++ data/themes/blank/templates/post-project.html | 22 ++++++++++++++++++++++ data/themes/default/templates/blog-post.html | 21 --------------------- data/themes/default/templates/page.html | 24 ------------------------ data/themes/default/templates/post-blog.html | 21 +++++++++++++++++++++ data/themes/default/templates/post-page.html | 24 ++++++++++++++++++++++++ data/themes/default/templates/post-project.html | 24 ++++++++++++++++++++++++ data/themes/default/templates/project.html | 24 ------------------------ src/guff/handlers.cr | 8 ++++---- src/guff/views/blog/list-item.cr | 7 ------- src/guff/views/blog/list.cr | 2 +- src/guff/views/blog/post.cr | 20 -------------------- src/guff/views/page.cr | 14 -------------- src/guff/views/posts/blog.cr | 20 ++++++++++++++++++++ src/guff/views/posts/page.cr | 14 ++++++++++++++ src/guff/views/posts/project.cr | 13 +++++++++++++ src/guff/views/project.cr | 13 ------------- 21 files changed, 198 insertions(+), 143 deletions(-) create mode 100644 data/themes/blank/templates/blog-list-item.html create mode 100644 data/themes/blank/templates/blog-list.html delete mode 100644 data/themes/blank/templates/page.html create mode 100644 data/themes/blank/templates/post-blog.html create mode 100644 data/themes/blank/templates/post-page.html create mode 100644 data/themes/blank/templates/post-project.html delete mode 100644 data/themes/default/templates/blog-post.html delete mode 100644 data/themes/default/templates/page.html create mode 100644 data/themes/default/templates/post-blog.html create mode 100644 data/themes/default/templates/post-page.html create mode 100644 data/themes/default/templates/post-project.html delete mode 100644 data/themes/default/templates/project.html delete mode 100644 src/guff/views/blog/list-item.cr delete mode 100644 src/guff/views/blog/post.cr delete mode 100644 src/guff/views/page.cr create mode 100644 src/guff/views/posts/blog.cr create mode 100644 src/guff/views/posts/page.cr create mode 100644 src/guff/views/posts/project.cr delete mode 100644 src/guff/views/project.cr diff --git a/data/themes/blank/templates/blog-list-item.html b/data/themes/blank/templates/blog-list-item.html new file mode 100644 index 0000000..f2c6c9f --- /dev/null +++ b/data/themes/blank/templates/blog-list-item.html @@ -0,0 +1,8 @@ +
+ %{name|h}
+ + by %{user_name|h} + on %{posted_at_text|h} +

+ %{body} +
diff --git a/data/themes/blank/templates/blog-list.html b/data/themes/blank/templates/blog-list.html new file mode 100644 index 0000000..0ed98f0 --- /dev/null +++ b/data/themes/blank/templates/blog-list.html @@ -0,0 +1,17 @@ + + + + + %{name|h} + + %{styles} + + + +
%{ + body + }
+ + + %{scripts} + diff --git a/data/themes/blank/templates/page.html b/data/themes/blank/templates/page.html deleted file mode 100644 index 78737aa..0000000 --- a/data/themes/blank/templates/page.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - %{name | h} - - %{styles} - - - - %{body} - - - %{scripts} - diff --git a/data/themes/blank/templates/post-blog.html b/data/themes/blank/templates/post-blog.html new file mode 100644 index 0000000..ec99b37 --- /dev/null +++ b/data/themes/blank/templates/post-blog.html @@ -0,0 +1,15 @@ + + + + + %{name|h} + + %{styles} + + + + %{body} + + + %{scripts} + diff --git a/data/themes/blank/templates/post-page.html b/data/themes/blank/templates/post-page.html new file mode 100644 index 0000000..264d152 --- /dev/null +++ b/data/themes/blank/templates/post-page.html @@ -0,0 +1,15 @@ + + + + + %{name | h} + + %{styles} + + + + %{body} + + + %{scripts} + diff --git a/data/themes/blank/templates/post-project.html b/data/themes/blank/templates/post-project.html new file mode 100644 index 0000000..3fd5a76 --- /dev/null +++ b/data/themes/blank/templates/post-project.html @@ -0,0 +1,22 @@ + + + + + %{name | h} + + %{styles} + + + + %{body} + +

+ %{repo_url|h} +

+ + + %{scripts} + diff --git a/data/themes/default/templates/blog-post.html b/data/themes/default/templates/blog-post.html deleted file mode 100644 index f1eaeb4..0000000 --- a/data/themes/default/templates/blog-post.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - %{name|h} - - %{styles} - - - - blog post: %{name|h}
- - by %{user_name|h} - on %{posted_at_text|h} -

- - %{body} - - - %{scripts} - diff --git a/data/themes/default/templates/page.html b/data/themes/default/templates/page.html deleted file mode 100644 index 24f2290..0000000 --- a/data/themes/default/templates/page.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - %{ - name | h - } - - %{styles} - - - -
- page: %{name | h}
- - by %{user_name | h} - on %{posted_at_text | h} -

- %{body} -
- - - %{scripts} - diff --git a/data/themes/default/templates/post-blog.html b/data/themes/default/templates/post-blog.html new file mode 100644 index 0000000..0facb3b --- /dev/null +++ b/data/themes/default/templates/post-blog.html @@ -0,0 +1,21 @@ + + + + + %{name|h} + + %{styles} + + + + blog post: %{name|h}
+ + by %{user_name|h} + on %{posted_at_text|h} +

+ + %{body} + + + %{scripts} + diff --git a/data/themes/default/templates/post-page.html b/data/themes/default/templates/post-page.html new file mode 100644 index 0000000..fdd4523 --- /dev/null +++ b/data/themes/default/templates/post-page.html @@ -0,0 +1,24 @@ + + + + + %{ + name | h + } + + %{styles} + + + +
+ page: %{name | h}
+ + by %{user_name | h} + on %{posted_at_text | h} +

+ %{body} +
+ + + %{scripts} + diff --git a/data/themes/default/templates/post-project.html b/data/themes/default/templates/post-project.html new file mode 100644 index 0000000..725cab0 --- /dev/null +++ b/data/themes/default/templates/post-project.html @@ -0,0 +1,24 @@ + + + + + %{name | h} + + %{styles} + + + + Project: %{name | h}
+ %{body} + +

+ Repo URL: %{repo_url|h} +

+ + + + %{scripts} + diff --git a/data/themes/default/templates/project.html b/data/themes/default/templates/project.html deleted file mode 100644 index c62227a..0000000 --- a/data/themes/default/templates/project.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Project: %{name | h} - - %{styles} - - - - Project: %{name | h}
- %{body} - -

- Repo URL: %{repo_url|h} -

- - - - %{scripts} - diff --git a/src/guff/handlers.cr b/src/guff/handlers.cr index 8c3e550..ce52b6a 100644 --- a/src/guff/handlers.cr +++ b/src/guff/handlers.cr @@ -357,7 +357,7 @@ module Guff::Handlers context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - Views::PageView.new(@context, r).to_s(context.response) + Views::Posts::Page.new(@context, r).to_s(context.response) else # unknown page call_next(context) @@ -400,7 +400,7 @@ module Guff::Handlers context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - Views::ProjectView.new(@context, r).to_s(context.response) + Views::Posts::Project.new(@context, r).to_s(context.response) else # redirect to project context.response.headers["location"] = path + "/" @@ -451,7 +451,7 @@ module Guff::Handlers context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - Views::Blog::PostView.new(@context, site_id, r).to_s(context.response) + Views::Posts::Blog.new(@context, site_id, r).to_s(context.response) else # unknown page call_next(context) @@ -505,7 +505,7 @@ module Guff::Handlers context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - Views::Blog::ListView.new(@context, site_id, r).to_s(context.response) + Views::Blog::List.new(@context, site_id, r).to_s(context.response) else # unknown page call_next(context) diff --git a/src/guff/views/blog/list-item.cr b/src/guff/views/blog/list-item.cr deleted file mode 100644 index 12add51..0000000 --- a/src/guff/views/blog/list-item.cr +++ /dev/null @@ -1,7 +0,0 @@ -class Guff::Views::Blog::ListItemView < Guff::Views::HTMLView - def initialize(context : Context, @item : Hash(String, String)) - super(context) - end - - ECR.def_to_s("src/views/blog/list-item.ecr") -end diff --git a/src/guff/views/blog/list.cr b/src/guff/views/blog/list.cr index 00bd587..f97aea6 100644 --- a/src/guff/views/blog/list.cr +++ b/src/guff/views/blog/list.cr @@ -3,7 +3,7 @@ require "../template-html" # # TODO: add y/m/d/page # -class Guff::Views::Blog::ListView < Guff::Views::TemplateHTMLView +class Guff::Views::Blog::List < Guff::Views::TemplateHTMLView TITLE = "Blog List" def initialize( diff --git a/src/guff/views/blog/post.cr b/src/guff/views/blog/post.cr deleted file mode 100644 index 4bc5282..0000000 --- a/src/guff/views/blog/post.cr +++ /dev/null @@ -1,20 +0,0 @@ -require "../template-html" - -class Guff::Views::Blog::PostView < Guff::Views::TemplateHTMLView - def initialize( - context : Context, - site_id : Int64, - item : Hash(String, String) - ) - # get site details - site = context.models.site.get(site_id) - - super( - context: context, - theme_id: site["theme_id"].as(Int64).to_i32, - theme_slug: site["theme_slug"].as(String), - template_id: "blog-post.html", - data: item, - ) - end -end diff --git a/src/guff/views/page.cr b/src/guff/views/page.cr deleted file mode 100644 index 7d386c2..0000000 --- a/src/guff/views/page.cr +++ /dev/null @@ -1,14 +0,0 @@ -require "./template-html" - -class Guff::Views::PageView < Guff::Views::TemplateHTMLView - def initialize(context : Context, @item : Hash(String, String)) - super( - context: context, - theme_id: @item["active_theme_id"].not_nil!.to_i32 as Int32, - theme_slug: @item["active_theme_slug"].not_nil!.to_s as String, - template_id: "page.html", - data: @item, - extra_assets: context.models.page.assets(@item["post_id"].to_i64) as Theme::Assets, - ) - end -end diff --git a/src/guff/views/posts/blog.cr b/src/guff/views/posts/blog.cr new file mode 100644 index 0000000..6634bca --- /dev/null +++ b/src/guff/views/posts/blog.cr @@ -0,0 +1,20 @@ +require "../template-html" + +class Guff::Views::Posts::Blog < Guff::Views::TemplateHTMLView + def initialize( + context : Context, + site_id : Int64, + item : Hash(String, String) + ) + # get site details + site = context.models.site.get(site_id) + + super( + context: context, + theme_id: site["theme_id"].as(Int64).to_i32, + theme_slug: site["theme_slug"].as(String), + template_id: "post-blog.html", + data: item, + ) + end +end diff --git a/src/guff/views/posts/page.cr b/src/guff/views/posts/page.cr new file mode 100644 index 0000000..55f5004 --- /dev/null +++ b/src/guff/views/posts/page.cr @@ -0,0 +1,14 @@ +require "../template-html" + +class Guff::Views::Posts::Page < Guff::Views::TemplateHTMLView + def initialize(context : Context, @item : Hash(String, String)) + super( + context: context, + theme_id: @item["active_theme_id"].not_nil!.to_i32 as Int32, + theme_slug: @item["active_theme_slug"].not_nil!.to_s as String, + template_id: "post-page.html", + data: @item, + extra_assets: context.models.page.assets(@item["post_id"].to_i64) as Theme::Assets, + ) + end +end diff --git a/src/guff/views/posts/project.cr b/src/guff/views/posts/project.cr new file mode 100644 index 0000000..3da0a64 --- /dev/null +++ b/src/guff/views/posts/project.cr @@ -0,0 +1,13 @@ +require "../template-html" + +class Guff::Views::Posts::Project < Guff::Views::TemplateHTMLView + def initialize(context : Context, @item : Hash(String, String)) + super( + context: context, + theme_id: @item["theme_id"].to_i32, + theme_slug: @item["theme_slug"], + template_id: "post-project.html", + data: @item, + ) + end +end diff --git a/src/guff/views/project.cr b/src/guff/views/project.cr deleted file mode 100644 index fc91b5c..0000000 --- a/src/guff/views/project.cr +++ /dev/null @@ -1,13 +0,0 @@ -require "./template-html" - -class Guff::Views::ProjectView < Guff::Views::TemplateHTMLView - def initialize(context : Context, @item : Hash(String, String)) - super( - context: context, - theme_id: @item["theme_id"].not_nil!.to_i32 as Int32, - theme_slug: @item["theme_slug"].not_nil!.to_s as String, - template_id: "project.html", - data: @item, - ) - end -end -- cgit v1.2.3