Skip to content

Commit 4c9a6ab

Browse files
committed
Merge branch 'new-ft-blog-platform'
2 parents c247ee7 + 5ac3eaa commit 4c9a6ab

17 files changed

+113
-7
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# or operating system, you probably want to add a global ignore instead:
55
# git config --global core.excludesfile '~/.gitignore_global'
66

7-
# Ignore bundler config.
7+
# Ignore bundler config & bundler gems
88
/.bundle
9+
vendor/bundle
910

1011
# Ignore the default SQLite database.
1112
/db/*.sqlite3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class BlogOverviewPageController < CmsController
2+
POSTS_PER_PAGE = 10
3+
4+
def index
5+
offset = params[:offset].to_i
6+
7+
blog_posts_query = BlogPostPage.all.order(created: :desc)
8+
blog_posts_query.batch_size(POSTS_PER_PAGE).offset(offset)
9+
@blog_posts = blog_posts_query.take(POSTS_PER_PAGE)
10+
11+
total = blog_posts_query.size
12+
13+
if offset > 0
14+
@previous_page = scrivito_path(@obj, offset: offset - POSTS_PER_PAGE)
15+
end
16+
17+
if total > offset + POSTS_PER_PAGE
18+
@next_page = scrivito_path(@obj, offset: offset + POSTS_PER_PAGE)
19+
end
20+
end
21+
22+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class BlogPageController < CmsController
2+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class BlogPostPageController < CmsController
2+
end

app/models/blog_overview_page.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class BlogOverviewPage < Obj
2+
attribute :title, :string
3+
attribute :body, :widgetlist
4+
attribute :child_order, :referencelist
5+
end

app/models/blog_page.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class BlogPage < Obj
2+
attribute :title, :string
3+
attribute :image, :reference
4+
attribute :body, :widgetlist
5+
attribute :child_order, :referencelist
6+
end

app/models/blog_post_page.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class BlogPostPage < Obj
2+
attribute :title, :string
3+
attribute :image, :reference
4+
attribute :body, :widgetlist
5+
attribute :created, :date
6+
attribute :abstract, :html
7+
8+
default_for :created do
9+
Time.zone.now
10+
end
11+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%= scrivito_medium_dialog do %>
2+
<%= scrivito_details_for "Title" do %>
3+
<%= scrivito_tag :div, @obj, :title %>
4+
<% end %>
5+
<% end %>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class ="row">
2+
<div class="col-lg-12">
3+
<h1 class="page-header">Page Overview </h1>
4+
</div>
5+
</div>
6+
<% @blog_posts.each do |blog_post| %>
7+
<div class="row">
8+
<div class="col-md-7">
9+
<%= scrivito_image_tag(scrivito_value(blog_post.image), :class => "img-responsive") %>
10+
</div>
11+
<div class="col-md-5">
12+
<h3><%= link_to(scrivito_value(blog_post.title), scrivito_path(blog_post)) %></h3>
13+
<%= content_tag(:p, scrivito_value(blog_post.abstract)) %>
14+
<%= link_to("View Post", scrivito_path(blog_post), :class => "btn btn-primary") %>
15+
</div>
16+
</div>
17+
<hr>
18+
<% end %>
19+
20+
<%= link_to("previous page", @previous_page) if @previous_page %>
21+
<%= link_to("next page", @next_page) if @next_page %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= scrivito_thumbnail BlogOverviewPage.description_for_editor, :content %>

app/views/blog_page/details.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%= scrivito_medium_dialog do %>
2+
<%= scrivito_details_for "Title" do %>
3+
<%= scrivito_tag :div, @obj, :title %>
4+
<% end %>
5+
<% end %>

app/views/blog_page/index.html.erb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<%= scrivito_tag_list :ul, @obj, :toclist do |list, child| %>
2+
<%= list.tag :li do %>
3+
<%= link_to child.display_title, scrivito_path(child) %>
4+
<% end %>
5+
<% end %>
6+
7+
<%= scrivito_tag :h1, @obj, :title %>
8+
<%= scrivito_tag :div, @obj, :body %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= scrivito_thumbnail BlogPage.description_for_editor, :content %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%= scrivito_medium_dialog do %>
2+
<%= scrivito_details_for "Title" do %>
3+
<%= scrivito_tag :div, @obj, :title %>
4+
<% end %>
5+
<% end %>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%= scrivito_tag_list :ul, @obj, :toclist do |list, child| %>
2+
<%= list.tag :li do %>
3+
<%= link_to child.display_title, scrivito_path(child) %>
4+
<% end %>
5+
<% end %>
6+
7+
<%= scrivito_tag :h1, @obj, :title %>
8+
<%= scrivito_tag(:div, @obj, :abstract) %>
9+
<%= scrivito_tag(:div, @obj, :created) %>
10+
<%= scrivito_image_tag(@obj, :image) %>
11+
<%= scrivito_tag :div, @obj, :body %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= scrivito_thumbnail BlogPostPage.description_for_editor, :content %>

app/views/layouts/application.html.erb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
</head>
1111
<body>
12-
<center>
13-
<row>
14-
<%= yield %>
15-
<%= scrivito_body_tags %>
16-
</row>
17-
</center>
12+
<div class="container">
13+
14+
<%= yield %>
15+
<%= scrivito_body_tags %>
16+
</div>
1817
</body>
1918
</html>

0 commit comments

Comments
 (0)