From 7c07686126d52fd7f77624af37c62db3c38505f0 Mon Sep 17 00:00:00 2001 From: Yohei YASUKAWA Date: Sat, 3 Dec 2016 14:20:37 +0800 Subject: [PATCH 1/5] Add routing to SoTechSha#index --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index ac3094310..c27f29d1c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do # Accsess from CoderDojo Book + get '/sotechsha', to: 'so_tech_sha#index' get '/sotechsha/:quiz', to: 'so_tech_sha#quiz' # Default Scrivito routes. Adapt them to change the routing of CMS objects. From e98020cfae7a3752de56ec7711195b19e4b58d5e Mon Sep 17 00:00:00 2001 From: Yohei YASUKAWA Date: Sat, 3 Dec 2016 14:21:02 +0800 Subject: [PATCH 2/5] Align indent in routes.rb --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index c27f29d1c..7fa0b43eb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,7 +5,7 @@ # Default Scrivito routes. Adapt them to change the routing of CMS objects. # See the documentation of 'scrivito_route' for a detailed description. - scrivito_route '/', using: 'homepage' + scrivito_route '/', using: 'homepage' scrivito_route '(/)(*slug-):id', using: 'slug_id' - scrivito_route '/*permalink', using: 'permalink', format: false + scrivito_route '/*permalink', using: 'permalink', format: false end From 4761b9cdd2e57f273cd1064f309a23a9e6c3a33a Mon Sep 17 00:00:00 2001 From: tomoko Date: Tue, 6 Dec 2016 16:18:25 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9C=AC=E3=81=AB=E9=96=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E8=A8=98=E4=BA=8B=E3=81=AE=E3=83=91=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=81=9F=E3=82=81=E3=80=81=E5=BD=B1=E9=9F=BF=E3=81=99?= =?UTF-8?q?=E3=82=8Bcontroller/test=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/so_tech_sha_controller.rb | 2 +- db/test | Bin 12288 -> 12288 bytes test/integration/so_tech_sha_test.rb | 7 ++++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/so_tech_sha_controller.rb b/app/controllers/so_tech_sha_controller.rb index 8ad748dc4..738a7b728 100644 --- a/app/controllers/so_tech_sha_controller.rb +++ b/app/controllers/so_tech_sha_controller.rb @@ -1,6 +1,6 @@ class SoTechShaController < ApplicationController def quiz quiz = params[:quiz] - redirect_to "/#{quiz}" + redirect_to "/sotechsha-#{quiz}" end end diff --git a/db/test b/db/test index ee89cfdf9ea3812c5272e126ee94ca476dc65606..6c406278beb5c63259be25bd74e77499a2bde4af 100644 GIT binary patch delta 31 ncmZojXh@il#P_#=mw|zSiJyake-b~(W delta 31 ncmZojXh@il#P^Jgmw|zSiJyake-b~(W Date: Tue, 6 Dec 2016 17:24:12 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9C=AC=E3=81=AB=E9=96=A2=E3=81=99?= =?UTF-8?q?=E3=82=8B=E8=A8=98=E4=BA=8B=E3=81=AE=E4=B8=80=E8=A6=A7=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=83=9A=E3=83=BC=E3=82=B8=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../so_tech_sha_overview_page_controller.rb | 22 +++++++++++++++++++ app/models/so_tech_sha_overview_page.rb | 5 +++++ .../details.html.erb | 5 +++++ .../so_tech_sha_overview_page/index.html.erb | 21 ++++++++++++++++++ .../thumbnail.html.erb | 1 + config/routes.rb | 2 +- test/integration/so_tech_sha_test.rb | 7 ++++++ 7 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 app/controllers/so_tech_sha_overview_page_controller.rb create mode 100644 app/models/so_tech_sha_overview_page.rb create mode 100644 app/views/so_tech_sha_overview_page/details.html.erb create mode 100644 app/views/so_tech_sha_overview_page/index.html.erb create mode 100644 app/views/so_tech_sha_overview_page/thumbnail.html.erb diff --git a/app/controllers/so_tech_sha_overview_page_controller.rb b/app/controllers/so_tech_sha_overview_page_controller.rb new file mode 100644 index 000000000..0abcdc8ee --- /dev/null +++ b/app/controllers/so_tech_sha_overview_page_controller.rb @@ -0,0 +1,22 @@ +class SoTechShaOverviewPageController < CmsController + POSTS_PER_PAGE = 10 + + def index + offset = params[:offset].to_i + + sts_posts_query = BlogPostPage.where(:_permalink, :starts_with, 'sotechsha-') + sts_posts_query.batch_size(POSTS_PER_PAGE).offset(offset) + @sts_posts = sts_posts_query.take(POSTS_PER_PAGE) + + total = sts_posts_query.size + + if offset > 0 + @previous_page = scrivito_path(@obj, offset: offset - POSTS_PER_PAGE) + end + + if total > offset + POSTS_PER_PAGE + @next_page = scrivito_path(@obj, offset: offset + POSTS_PER_PAGE) + end + end + +end diff --git a/app/models/so_tech_sha_overview_page.rb b/app/models/so_tech_sha_overview_page.rb new file mode 100644 index 000000000..840d722db --- /dev/null +++ b/app/models/so_tech_sha_overview_page.rb @@ -0,0 +1,5 @@ +class SoTechShaOverviewPage < Obj + attribute :title, :string + attribute :body, :widgetlist + attribute :child_order, :referencelist +end diff --git a/app/views/so_tech_sha_overview_page/details.html.erb b/app/views/so_tech_sha_overview_page/details.html.erb new file mode 100644 index 000000000..c28b0daa5 --- /dev/null +++ b/app/views/so_tech_sha_overview_page/details.html.erb @@ -0,0 +1,5 @@ +<%= scrivito_medium_dialog do %> + <%= scrivito_details_for "Title" do %> + <%= scrivito_tag :div, @obj, :title %> + <% end %> +<% end %> diff --git a/app/views/so_tech_sha_overview_page/index.html.erb b/app/views/so_tech_sha_overview_page/index.html.erb new file mode 100644 index 000000000..81da8926d --- /dev/null +++ b/app/views/so_tech_sha_overview_page/index.html.erb @@ -0,0 +1,21 @@ +
+
+

「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ

+
+
+<% @sts_posts.each do |sts_post| %> +
+
+ <%= scrivito_image_tag(scrivito_value(sts_post.image), :class => "img-responsive") %> +
+
+

<%= link_to(scrivito_value(sts_post.title), scrivito_path(sts_post)) %>

+ <%= content_tag(:p, scrivito_value(sts_post.abstract)) %> + <%= link_to("View Post", scrivito_path(sts_post), :class => "btn btn-primary") %> +
+
+
+<% end %> + +<%= link_to("previous page", @previous_page) if @previous_page %> +<%= link_to("next page", @next_page) if @next_page %> diff --git a/app/views/so_tech_sha_overview_page/thumbnail.html.erb b/app/views/so_tech_sha_overview_page/thumbnail.html.erb new file mode 100644 index 000000000..3ae4a3f67 --- /dev/null +++ b/app/views/so_tech_sha_overview_page/thumbnail.html.erb @@ -0,0 +1 @@ +<%= scrivito_thumbnail SoTechShaOverviewPage.description_for_editor, :content %> diff --git a/config/routes.rb b/config/routes.rb index 7fa0b43eb..1adff3e8c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ Rails.application.routes.draw do # Accsess from CoderDojo Book - get '/sotechsha', to: 'so_tech_sha#index' + get '/sotechsha', to: 'so_tech_sha_overview_page#index' get '/sotechsha/:quiz', to: 'so_tech_sha#quiz' # Default Scrivito routes. Adapt them to change the routing of CMS objects. diff --git a/test/integration/so_tech_sha_test.rb b/test/integration/so_tech_sha_test.rb index 7abf0972a..812124dbc 100644 --- a/test/integration/so_tech_sha_test.rb +++ b/test/integration/so_tech_sha_test.rb @@ -17,4 +17,11 @@ def setup get "/sotechsha/gazou" assert_redirected_to "/sotechsha-gazou" end + + test "SoTechShalink should be rendered" do + get "/sotechsha" + #so_tech_sha_overview_page.index がrenderされる + #タイトルが「「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ」である + #記事の件数 7件である + end end From 164f3d6f620b38e1adb5acb1852bdb4c7cfbd661 Mon Sep 17 00:00:00 2001 From: tomoko Date: Wed, 7 Dec 2016 19:43:36 +0900 Subject: [PATCH 5/5] =?UTF-8?q?GET=20/blog=20=E3=81=A8GET=20/sotechsha?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 本の記事一覧のソートを追加 --- .../so_tech_sha_overview_page_controller.rb | 2 +- app/views/blog_overview_page/index.html.erb | 2 +- app/views/so_tech_sha_overview_page/index.html.erb | 2 +- test/integration/blog_test.rb | 12 ++++++++++++ test/integration/so_tech_sha_test.rb | 8 +++++--- 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 test/integration/blog_test.rb diff --git a/app/controllers/so_tech_sha_overview_page_controller.rb b/app/controllers/so_tech_sha_overview_page_controller.rb index 0abcdc8ee..ac54861bd 100644 --- a/app/controllers/so_tech_sha_overview_page_controller.rb +++ b/app/controllers/so_tech_sha_overview_page_controller.rb @@ -4,7 +4,7 @@ class SoTechShaOverviewPageController < CmsController def index offset = params[:offset].to_i - sts_posts_query = BlogPostPage.where(:_permalink, :starts_with, 'sotechsha-') + sts_posts_query = BlogPostPage.where(:_permalink, :starts_with, 'sotechsha-').order(created: :asc) sts_posts_query.batch_size(POSTS_PER_PAGE).offset(offset) @sts_posts = sts_posts_query.take(POSTS_PER_PAGE) diff --git a/app/views/blog_overview_page/index.html.erb b/app/views/blog_overview_page/index.html.erb index e9b5964a9..d0fb47c94 100644 --- a/app/views/blog_overview_page/index.html.erb +++ b/app/views/blog_overview_page/index.html.erb @@ -1,6 +1,6 @@
-

Page Overview

+

Page Overview

<% @blog_posts.each do |blog_post| %> diff --git a/app/views/so_tech_sha_overview_page/index.html.erb b/app/views/so_tech_sha_overview_page/index.html.erb index 81da8926d..4c21dc773 100644 --- a/app/views/so_tech_sha_overview_page/index.html.erb +++ b/app/views/so_tech_sha_overview_page/index.html.erb @@ -11,7 +11,7 @@

<%= link_to(scrivito_value(sts_post.title), scrivito_path(sts_post)) %>

<%= content_tag(:p, scrivito_value(sts_post.abstract)) %> - <%= link_to("View Post", scrivito_path(sts_post), :class => "btn btn-primary") %> + <%= link_to("もっと読む", scrivito_path(sts_post), :class => "btn btn-primary") %>

diff --git a/test/integration/blog_test.rb b/test/integration/blog_test.rb new file mode 100644 index 000000000..48e8f48ff --- /dev/null +++ b/test/integration/blog_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' + +class BlogTest < ActionDispatch::IntegrationTest + def setup + end + + test "Bloglink should be rendered" do + get "/blog" + assert_template "blog_overview_page/index" + assert_select "h1.page-header","Page Overview" + end +end diff --git a/test/integration/so_tech_sha_test.rb b/test/integration/so_tech_sha_test.rb index 812124dbc..3ce2996cf 100644 --- a/test/integration/so_tech_sha_test.rb +++ b/test/integration/so_tech_sha_test.rb @@ -20,8 +20,10 @@ def setup test "SoTechShalink should be rendered" do get "/sotechsha" - #so_tech_sha_overview_page.index がrenderされる - #タイトルが「「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ」である - #記事の件数 7件である + assert_template "so_tech_sha_overview_page/index" + assert_select "h1.page-header","「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ" + assert_select "a[href]", count:14 + # Error + # assert_select "a[href=?]", /sotechsha-/ , count:14 end end