From bd4dc5df7f0305b7100b850c315cf8f2aeb2328e Mon Sep 17 00:00:00 2001 From: yasushiito Date: Thu, 30 May 2013 19:15:19 +0900 Subject: [PATCH] top page moved --- app/controllers/comics_controller.rb | 6 ----- app/controllers/panels_controller.rb | 2 +- app/controllers/top_controller.rb | 24 ++++++++++++++++++ app/helpers/top_helper.rb | 2 ++ app/views/layouts/test.html.erb | 7 +++++- app/views/panels/_form.html.erb | 29 ++++++++++++++++++++++ app/views/panels/new.html.erb | 1 - .../{comics/top.html.erb => top/index.html.erb} | 6 ++--- app/views/top/metro.html.erb | 3 +++ config/locales/pettanr.ja.yml | 14 +++++++---- config/routes.rb | 7 +++--- spec/controllers/top_controller_spec.rb | 5 ++++ spec/helpers/top_helper_spec.rb | 15 +++++++++++ 13 files changed, 101 insertions(+), 20 deletions(-) create mode 100644 app/controllers/top_controller.rb create mode 100644 app/helpers/top_helper.rb rename app/views/{comics/top.html.erb => top/index.html.erb} (90%) create mode 100644 app/views/top/metro.html.erb create mode 100644 spec/controllers/top_controller_spec.rb create mode 100644 spec/helpers/top_helper_spec.rb diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index e7a071d5..b01247d2 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -10,12 +10,6 @@ class ComicsController < ApplicationController end before_filter :authenticate_admin!, :only => [:list, :browse] - def top - respond_to do |format| - format.html - end - end - def index @page = Comic.page params[:page] @page_size = Comic.page_size params[:page_size] diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index f099e644..757d3e60 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -71,7 +71,7 @@ class PanelsController < ApplicationController @panel.supply_default respond_to do |format| - format.html { render layout: 'metro' } + format.html format.js format.json { render json: @panel.panel_elements_as_json } end diff --git a/app/controllers/top_controller.rb b/app/controllers/top_controller.rb new file mode 100644 index 00000000..246004c8 --- /dev/null +++ b/app/controllers/top_controller.rb @@ -0,0 +1,24 @@ +class TopController < ApplicationController + layout 'test' if MagicNumber['test_layout'] + if MagicNumber['run_mode'] == 0 + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] + else + before_filter :authenticate_reader, :only => [:index, :metro] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] + end + + def index + respond_to do |format| + format.html + end + end + + def metro + respond_to do |format| + format.html { render layout: 'metro' } + end + end + +end diff --git a/app/helpers/top_helper.rb b/app/helpers/top_helper.rb new file mode 100644 index 00000000..b00ce697 --- /dev/null +++ b/app/helpers/top_helper.rb @@ -0,0 +1,2 @@ +module TopHelper +end diff --git a/app/views/layouts/test.html.erb b/app/views/layouts/test.html.erb index c463a6e0..4e1115ba 100644 --- a/app/views/layouts/test.html.erb +++ b/app/views/layouts/test.html.erb @@ -18,9 +18,14 @@
- +
+

<%= link_to MagicNumber['profile']['users']['caption'], main_app.root_path %>

+ <% if user_signed_in? %> + <%= link_to t('top.metro.title'), '/top/metro' %> + <% end %> +
<% if @author %> diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index 4499fd9e..3da00371 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -1,6 +1,35 @@ <%= form_for(@panel) do |f| %> <%= render 'system/error_explanation', :obj => @panel %> +
+ <%= f.label :caption %>
+ <%= f.text_field :caption %> +
+
+ <%= f.label :width %>
+ <%= f.number_field :width %> +
+
+ <%= f.label :height %>
+ <%= f.number_field :height %> +
+
+ <%= f.label :border %>
+ <%= f.number_field :border %> +
+
+ <%= f.label :publish %>
+ <%= f.collection_select :publish, t_select_items(MagicNumber['panel_visible_items']), :last, :first, :html => {:selected => @panel.publish} %> +
+
+ <%= f.submit %> +
+<% end %> + +

<%= t 'panels.create_from_json' -%>

+<%= form_for(@panel) do |f| %> + <%= render 'system/error_explanation', :obj => @panel %> +
diff --git a/app/views/panels/new.html.erb b/app/views/panels/new.html.erb index 3867ef84..fc4811c2 100644 --- a/app/views/panels/new.html.erb +++ b/app/views/panels/new.html.erb @@ -1,3 +1,2 @@

<%= t '.title' -%>

<%= render 'form' %> -

<%= link_to 'top', root_path %>

diff --git a/app/views/comics/top.html.erb b/app/views/top/index.html.erb similarity index 90% rename from app/views/comics/top.html.erb rename to app/views/top/index.html.erb index cadc31d7..c907d030 100644 --- a/app/views/comics/top.html.erb +++ b/app/views/top/index.html.erb @@ -1,7 +1,7 @@

<%= t '.title' -%>

<%= notice %>

-

<%= t('comics.top.user_resources') -%>

+

<%= t('top.user_resources') -%>

@@ -31,7 +31,7 @@
-

<%= t('comics.top.human_resources') -%>

+

<%= t('top.human_resources') -%>

@@ -46,7 +46,7 @@
-

<%= t('comics.top.system_resources') -%>

+

<%= t('top.system_resources') -%>

diff --git a/app/views/top/metro.html.erb b/app/views/top/metro.html.erb new file mode 100644 index 00000000..e6076d37 --- /dev/null +++ b/app/views/top/metro.html.erb @@ -0,0 +1,3 @@ +

<%= t '.title' -%>

+ + <%= link_to t('top.return'), root_path %> diff --git a/config/locales/pettanr.ja.yml b/config/locales/pettanr.ja.yml index 8663e328..a5a3c12b 100644 --- a/config/locales/pettanr.ja.yml +++ b/config/locales/pettanr.ja.yml @@ -409,6 +409,15 @@ ja: title: ログアウト sign_in: title: ログイン + top: + index: + title: 読む・探す + metro: + title: デスクトップアプリ風metroで体験 + user_resources: 発表作品から + human_resources: 人物から + system_resources: システムリソースから + return: シンプル版に戻る comics: index: title: コミック一覧 @@ -429,11 +438,6 @@ ja: title: コミック 生一覧 browse: title: コミック 生単票 - top: - title: 読む・探す - user_resources: 発表作品から - human_resources: 人物から - system_resources: システムリソースから stories: index: title: ストーリー一覧 diff --git a/config/routes.rb b/config/routes.rb index 08ac97b3..0181b024 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -339,10 +339,11 @@ Pettanr::Application.routes.draw do # Keep in mind you can assign values other than :controller and :action match 'resource_pictures/:subdir/:id(.:format)/' => 'resource_pictures#show' match 'pictures/:subdir/:id(.:format)/' => 'pictures#show' - match 'stories/comic/:id(.:format)' => 'stories#comic' + #match 'stories/comic/:id(.:format)' => 'stories#comic' + match 'top/(:action)', :controller => 'top' match 'home/(:action)', :controller => 'home' match 'system/(:action)', :controller => 'system' - match 'authors/(:action(/:id))', :controller => 'authors' + #match 'authors/(:action(/:id))', :controller => 'authors' # Sample of named route: # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase @@ -386,7 +387,7 @@ Pettanr::Application.routes.draw do # You can have the root of your site routed with "root" # just remember to delete public/index.html. - root :to => 'comics#top' + root :to => 'top#index' # See how all your routes lay out with "rake routes" diff --git a/spec/controllers/top_controller_spec.rb b/spec/controllers/top_controller_spec.rb new file mode 100644 index 00000000..ce83763d --- /dev/null +++ b/spec/controllers/top_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe TopController do + +end diff --git a/spec/helpers/top_helper_spec.rb b/spec/helpers/top_helper_spec.rb new file mode 100644 index 00000000..1927adf2 --- /dev/null +++ b/spec/helpers/top_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the TopHelper. For example: +# +# describe TopHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe TopHelper do + pending "add some examples to (or delete) #{__FILE__}" +end -- 2.11.0