リビジョン | 3bb159eda799aa3c5f19edb73ca9e44fbb6988db (tree) |
---|---|
日時 | 2012-01-15 14:42:01 |
作者 | ![]() |
コミッター | yasushiito |
iroiro
@@ -0,0 +1,3 @@ | ||
1 | +# Place all the behaviors and hooks related to the matching controller here. | |
2 | +# All this logic will automatically be available in application.js. | |
3 | +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
@@ -0,0 +1,3 @@ | ||
1 | +// Place all the styles related to the author_registrations controller here. | |
2 | +// They will automatically be included in application.css. | |
3 | +// You can use Sass (SCSS) here: http://sass-lang.com/ |
@@ -0,0 +1,7 @@ | ||
1 | +class AuthorRegistrationsController < Devise::RegistrationsController | |
2 | + protected | |
3 | + | |
4 | + def after_sign_up_path_for(resource) | |
5 | + '/home/step2' | |
6 | + end | |
7 | +end |
@@ -33,5 +33,5 @@ class AuthorsController < ApplicationController | ||
33 | 33 | format.html { render layout: 'system' } |
34 | 34 | end |
35 | 35 | end |
36 | - | |
36 | + | |
37 | 37 | end |
@@ -11,7 +11,12 @@ class ComicsController < ApplicationController | ||
11 | 11 | public |
12 | 12 | |
13 | 13 | def top |
14 | - @comics = Comic.all | |
14 | + @new_comics = Comic.find(:all, | |
15 | + :include => :author, :conditions => ['visible = 1'], :order => 'updated_at desc', :limit => 5 | |
16 | + ) | |
17 | + @new_pictures = OriginalPicture.find(:all, | |
18 | + :include => [:artist, :lisence, :resource_picture], :order => 'updated_at', :limit => 5 | |
19 | + ) | |
15 | 20 | |
16 | 21 | respond_to do |format| |
17 | 22 | format.html # index.html.erb |
@@ -1,8 +1,8 @@ | ||
1 | 1 | class HomeController < ApplicationController |
2 | - | |
3 | - def start | |
4 | - | |
5 | - end | |
2 | + before_filter :authenticate_author!, :only => [ | |
3 | + :index, :show, :profile, :configure, :create_token, :delete_token, :step2, :save_step2, :step3, :save_step3, | |
4 | + :comic, :picture | |
5 | + ] | |
6 | 6 | |
7 | 7 | def index |
8 | 8 | end |
@@ -10,4 +10,93 @@ class HomeController < ApplicationController | ||
10 | 10 | def profile |
11 | 11 | end |
12 | 12 | |
13 | + def configure | |
14 | + end | |
15 | + | |
16 | + def create_token | |
17 | + @author = current_author | |
18 | + respond_to do |format| | |
19 | + if @author.create_token | |
20 | + format.html { redirect_to({:action => :configure}, {:notice => 'author token was successfully created.'}) } | |
21 | + else | |
22 | + format.html { render action: "auth_token" } | |
23 | + end | |
24 | + end | |
25 | + end | |
26 | + | |
27 | + def delete_token | |
28 | + current_author.delete_token | |
29 | + respond_to do |format| | |
30 | + format.html { redirect_to :action => :configure} | |
31 | + end | |
32 | + end | |
33 | + | |
34 | + def step2 | |
35 | + @author = current_author | |
36 | + end | |
37 | + | |
38 | + def save_step2 | |
39 | + @author = current_author | |
40 | + respond_to do |format| | |
41 | + if @author.step2(params[:author][:name]) | |
42 | + a = if params[:step3].to_i == 1 | |
43 | + :step3 | |
44 | + else | |
45 | + :index | |
46 | + end | |
47 | + format.html { redirect_to({:action => a}, {:notice => 'your name was successfully updated.'}) } | |
48 | + else | |
49 | + format.html { render action: "step2" } | |
50 | + end | |
51 | + end | |
52 | + end | |
53 | + | |
54 | + def step3 | |
55 | + @artist = Artist.new :author_id => current_author.id, :name => current_author.name, :default_lisence_id => 1 | |
56 | + end | |
57 | + | |
58 | + def save_step3 | |
59 | + if current_author.artist? | |
60 | + redirect_to :action => :index | |
61 | + else | |
62 | + @artist = Artist.new params[:artist] | |
63 | + respond_to do |format| | |
64 | + if @artist.save | |
65 | + format.html { redirect_to({:action => :index}, {:notice => 'artist was successfully registered.'}) } | |
66 | + else | |
67 | + format.html { render action: "step3" } | |
68 | + end | |
69 | + end | |
70 | + end | |
71 | + end | |
72 | + | |
73 | + def comic | |
74 | + @comics = Comic.find(:all, | |
75 | + :include => :author, :conditions => ['author_id = ?', current_author.id], | |
76 | + :order => 'updated_at desc', :limit => 20 | |
77 | + ) | |
78 | + | |
79 | + respond_to do |format| | |
80 | + format.html # index.html.erb | |
81 | + format.json { render json: @comics } | |
82 | + end | |
83 | + end | |
84 | + | |
85 | + def picture | |
86 | + if current_author.artist? | |
87 | + @original_pictures = OriginalPicture.find(:all, | |
88 | + :include => [:artist, :lisence, :resource_picture], :conditions => ['artist_id = ?', current_author.artist.id], | |
89 | + :order => 'updated_at', :limit => 20 | |
90 | + ) | |
91 | + | |
92 | + respond_to do |format| | |
93 | + format.html # index.html.erb | |
94 | + format.json { render :json => @original_pictures.to_json( | |
95 | + :include => [:resource_picture, :artist, :lisence] | |
96 | + ) } | |
97 | + end | |
98 | + else | |
99 | + end | |
100 | + end | |
101 | + | |
13 | 102 | end |
@@ -4,7 +4,19 @@ class SystemController < ApplicationController | ||
4 | 4 | #layout :system |
5 | 5 | |
6 | 6 | def start |
7 | - | |
7 | + OriginalPicture.all.each do |a| | |
8 | + a.lisence_id = 1 if a.lisence_id.blank? | |
9 | + a.save | |
10 | + end | |
11 | + ResourcePicture.all.each do |a| | |
12 | + a.lisence_id = 1 if a.lisence_id.blank? | |
13 | + a.artist_id = 1 if a.artist_id.blank? | |
14 | + a.save | |
15 | + end | |
16 | + Artist.all.each do |a| | |
17 | + a.default_lisence_id = 1 if a.default_lisence_id.blank? | |
18 | + a.save | |
19 | + end | |
8 | 20 | end |
9 | 21 | |
10 | 22 | def index |
@@ -0,0 +1,2 @@ | ||
1 | +module AuthorRegistrationsHelper | |
2 | +end |
@@ -7,15 +7,29 @@ class Author < ActiveRecord::Base | ||
7 | 7 | :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable |
8 | 8 | |
9 | 9 | # Setup accessible (or protected) attributes for your model |
10 | - attr_accessible :email, :password, :password_confirmation, :remember_me | |
10 | + attr_accessible :id, :name, :password, :password_confirmation, :remember_me #, :email | |
11 | 11 | |
12 | - before_save :ensure_authentication_token | |
13 | 12 | before_save do |r| |
14 | 13 | r.name = 'no name' if r.name.blank? |
15 | 14 | end |
16 | 15 | |
17 | - def artist? | |
18 | - Artist.find_by_author(self) != nil | |
19 | - end | |
20 | - | |
16 | + def artist? | |
17 | + Artist.find_by_author(self) != nil | |
18 | + end | |
19 | + | |
20 | + def create_token | |
21 | + self.ensure_authentication_token | |
22 | + self.save | |
23 | + end | |
24 | + | |
25 | + def delete_token | |
26 | + self.authentication_token = nil | |
27 | + self.save | |
28 | + end | |
29 | + | |
30 | + def step2 n | |
31 | + self.name = n | |
32 | + self.save | |
33 | + end | |
34 | + | |
21 | 35 | end |
@@ -11,4 +11,8 @@ class Comic < ActiveRecord::Base | ||
11 | 11 | editable == 1 ? 'O' : 'X' |
12 | 12 | end |
13 | 13 | |
14 | + def disp_visible | |
15 | + visible == 1 ? 'O' : 'X' | |
16 | + end | |
17 | + | |
14 | 18 | end |
@@ -20,9 +20,9 @@ | ||
20 | 20 | <td><%= h artist.email %></td> |
21 | 21 | <td><%= h artist.name %></td> |
22 | 22 | <td><%= h artist.homepage_url %></td> |
23 | + <td><%= h artist.api_url %></td> | |
23 | 24 | <td><%= link_to artist.default_lisence_id, :controller => 'lisences', :action => :browse, :id => artist.default_lisence_id %></td> |
24 | 25 | <td><%= artist.crowled_at %></td> |
25 | - <td><%= h artist.api_url %></td> | |
26 | 26 | <td><%= link_to artist.author_id, :controller => 'authors', :action => :browse, :id => artist.author_id %></td> |
27 | 27 | <td><%= artist.created_at %></td> |
28 | 28 | <td><%= artist.updated_at %></td> |
@@ -0,0 +1,18 @@ | ||
1 | +<h2>Sign up</h2> | |
2 | + | |
3 | +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> | |
4 | + <%= devise_error_messages! %> | |
5 | + | |
6 | + <div><%= f.label :email %><br /> | |
7 | + <%= f.email_field :email %></div> | |
8 | + | |
9 | + <div><%= f.label :password %><br /> | |
10 | + <%= f.password_field :password %></div> | |
11 | + | |
12 | + <div><%= f.label :password_confirmation %><br /> | |
13 | + <%= f.password_field :password_confirmation %></div> | |
14 | + | |
15 | + <div><%= f.submit "Sign up" %></div> | |
16 | +<% end %> | |
17 | + | |
18 | +<%= render :partial => "devise/shared/links" %> |
@@ -3,9 +3,6 @@ | ||
3 | 3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> |
4 | 4 | <%= devise_error_messages! %> |
5 | 5 | |
6 | - <div><%= f.label :name %><br /> | |
7 | - <%= f.text_field :name %></div> | |
8 | - | |
9 | 6 | <div><%= f.label :email %><br /> |
10 | 7 | <%= f.email_field :email %></div> |
11 | 8 |
@@ -1,5 +1,6 @@ | ||
1 | -<h1><%= link_to '新着', comics_path %></h1> | |
2 | - | |
1 | +<%= link_to "comics", comics_path %> | |
2 | +<h1>コミック</h1> | |
3 | +<%= link_to '新着', comics_path %> | |
3 | 4 | <table> |
4 | 5 | <tr> |
5 | 6 | <th>Title</th> |
@@ -9,7 +10,7 @@ | ||
9 | 10 | <th></th> |
10 | 11 | </tr> |
11 | 12 | |
12 | -<% @comics.each do |comic| %> | |
13 | +<% @new_comics.each do |comic| %> | |
13 | 14 | <tr> |
14 | 15 | <td><%= link_to h(comic.title), :action => :play, :id => comic.id %></td> |
15 | 16 | <td><%= comic.editable %></td> |
@@ -25,5 +26,17 @@ | ||
25 | 26 | </tr> |
26 | 27 | <% end %> |
27 | 28 | </table> |
28 | -<h1>人気</h1> | |
29 | - | |
29 | +<%= link_to '人気', comics_path %> | |
30 | +<h3>コマ</h3> | |
31 | +<%= link_to '新着', panels_path %> | |
32 | +<%= link_to '人気', panels_path %> | |
33 | +<h1>素材</h1> | |
34 | +<% @new_pictures.each do |picture| %> | |
35 | + <div> | |
36 | + <img src="<%= picture.resource_picture.url('thumbnail') -%>"> | |
37 | + 画:<%= h picture.artist.name %> | |
38 | + </div> | |
39 | +<% end %> | |
40 | +<%= link_to "もっと見る", original_pictures_path %> | |
41 | +<h3>ライセンス</h3> | |
42 | +<%= link_to "lisences", lisences_path %> |
@@ -0,0 +1,14 @@ | ||
1 | +<h1>Listing comics</h1> | |
2 | + | |
3 | +<% @comics.each do |comic| %> | |
4 | + <div> | |
5 | + <div> | |
6 | + <%= link_to h(comic.title), :action => :play, :id => comic.id %> | |
7 | + 一般投稿:<%= comic.disp_editable %> | |
8 | + 公開:<%= comic.disp_visible %> | |
9 | + </div> | |
10 | + <div> | |
11 | + 更新:<%= comic.updated_at %> | |
12 | + </div> | |
13 | + </div> | |
14 | +<% end %> |
@@ -0,0 +1,15 @@ | ||
1 | +<h2>認証トークン</h2> | |
2 | +<div> | |
3 | +あなたの認証トークンは<%= current_author.authentication_token %>です | |
4 | +</div> | |
5 | +<div> | |
6 | + <% if current_author.authentication_token %> | |
7 | + <%= link_to 'delete token', :action => :delete_token %> | |
8 | + <% else %> | |
9 | + <%= link_to 'generate token', :action => :create_token %> | |
10 | + <% end %> | |
11 | +</div> | |
12 | +<h2>退会</h2> | |
13 | +<div> | |
14 | + <%= link_to('退会する', {:controller => 'author_registrations', :action => :destroy, :id => current_author.id}, {:method => :delete}) %> | |
15 | +</div> |
@@ -1,7 +1,4 @@ | ||
1 | 1 | <h1><%= h(current_author.name) -%>(<%= h(current_author.email) -%>)</h1> |
2 | -<div> | |
3 | -あなたの認証トークンは<%= current_author.authentication_token %>です | |
4 | -</div> | |
5 | 2 | |
6 | 3 | <div> |
7 | 4 | <p>絵師活動</p> |
@@ -0,0 +1,10 @@ | ||
1 | +<h1>Listing my pictures</h1> | |
2 | + | |
3 | +<% @original_pictures.each do |original_picture| %> | |
4 | + <div> | |
5 | + <%= original_picture.filename %> | |
6 | + <img src="<%= original_picture.resource_picture.url('thumbnail') -%>"> | |
7 | + <%= original_picture.width %>x<%= original_picture.height %> | |
8 | + <%= original_picture.filesize %>bytes | |
9 | + </div> | |
10 | +<% end %> |
@@ -0,0 +1,32 @@ | ||
1 | +<h1>ようこそ、ぺったんRへ</h1> | |
2 | +<div> | |
3 | +<%= h(current_author.email) -%>さんはぺったんRで作家としてデビューしました。 | |
4 | +今すぐにでも作品を作れますが、より良い活動をするために作家名を登録してください。 | |
5 | +</div> | |
6 | +<%= form_for(:author, :url => {:controller => '/home', :action => :save_step2}) do |f| %> | |
7 | + <% if @author.errors.any? %> | |
8 | + <div id="error_explanation"> | |
9 | + <h2><%= pluralize(@author.errors.count, "error") %> prohibited this original_lisence from being saved:</h2> | |
10 | + | |
11 | + <ul> | |
12 | + <% @author.errors.full_messages.each do |msg| %> | |
13 | + <li><%= msg %></li> | |
14 | + <% end %> | |
15 | + </ul> | |
16 | + </div> | |
17 | + <% end %> | |
18 | + | |
19 | + <div class="field"> | |
20 | + <%= f.label :name %><br /> | |
21 | + <%= f.text_field :name %> | |
22 | + </div> | |
23 | + <p>あなたの素材を投稿してみませんか?</p> | |
24 | + 絵師としての情報を登録すれば、あなたのキャラクターを漫画に登場させるなど、幅広い創作活動ができます。 | |
25 | + <div class="field"> | |
26 | + <%= check_box_tag 'step3', 1, false %> 引き続き、絵師登録を行う | |
27 | + </div> | |
28 | + | |
29 | + <div class="actions"> | |
30 | + <%= f.submit '次のステップへ' %> | |
31 | + </div> | |
32 | +<% end %> |
@@ -0,0 +1,31 @@ | ||
1 | +<h1>ようこそ、ぺったんRへ</h1> | |
2 | +<%= h(current_author.name) -%>さん | |
3 | +<div> | |
4 | + <%= form_for(:artist, :url => {:controller => '/home', :action => :save_step3}) do |f| %> | |
5 | + <% if @artist.errors.any? %> | |
6 | + <div id="error_explanation"> | |
7 | + <h2><%= pluralize(@artist.errors.count, "error") %> prohibited this artist from being saved:</h2> | |
8 | + | |
9 | + <ul> | |
10 | + <% @artist.errors.full_messages.each do |msg| %> | |
11 | + <li><%= msg %></li> | |
12 | + <% end %> | |
13 | + </ul> | |
14 | + </div> | |
15 | + <% end %> | |
16 | + | |
17 | + <div class="field"> | |
18 | + <p>作家名とは別に絵師としてのペンネームを設定できます。</p> | |
19 | + <%= f.label :name %><br /> | |
20 | + <%= f.text_field :name %><br /> | |
21 | + | |
22 | + <p>素材をアップロードするときのデフォルトライセンスを選択します。</p> | |
23 | + <%= f.label :default_lisence_id %><br /> | |
24 | + <%= f.select :default_lisence_id, Lisence.all.map {|l| [l.name, l.id] }, :html => {:selected => @artist.default_lisence_id} %> | |
25 | + <%= f.hidden_field :author_id, :value => @artist.author_id %> | |
26 | + </div> | |
27 | + <div class="actions"> | |
28 | + <%= f.submit '完了' %> | |
29 | + </div> | |
30 | + <% end %> | |
31 | +</div> |
@@ -12,12 +12,21 @@ | ||
12 | 12 | <div> |
13 | 13 | <% if author_signed_in? %> |
14 | 14 | <%= link_to "my home", :controller => '/home' %> |
15 | + <%= link_to "my comics", :controller => '/home', :action => :comic %> | |
16 | + <%= link_to "my pictures", :controller => '/home', :action => :picture %> | |
17 | + <%= link_to "config", :controller => '/home', :action => :configure %> | |
15 | 18 | <%= link_to "ログアウト", destroy_author_session_path, :method => :delete %> |
16 | 19 | <% else %> |
17 | 20 | <%= link_to "ログイン", new_author_session_path %> |
18 | 21 | <% end %> |
19 | 22 | </div> |
20 | 23 | <div> |
24 | + <p class="notice"><%= notice %></p> | |
25 | + <p class="alert"><%= alert %></p> | |
26 | +</div> | |
27 | +<%= yield %> | |
28 | + | |
29 | +<div> | |
21 | 30 | <% if admin_signed_in? %> |
22 | 31 | <%= link_to "system", :controller => '/system' %> |
23 | 32 | <%= link_to "ログアウト", destroy_admin_session_path, :method => :delete %> |
@@ -25,15 +34,5 @@ | ||
25 | 34 | <%= link_to "管理者", new_admin_session_path %> |
26 | 35 | <% end %> |
27 | 36 | </div> |
28 | -<div> | |
29 | - <p class="notice"><%= notice %></p> | |
30 | - <p class="alert"><%= alert %></p> | |
31 | -</div> | |
32 | -<%= link_to "comics", comics_path %> | |
33 | -<%= link_to "panels", panels_path %> | |
34 | -<%= link_to "pictures", original_pictures_path %> | |
35 | -<%= link_to "lisences", lisences_path %> | |
36 | -<%= yield %> | |
37 | - | |
38 | 37 | </body> |
39 | 38 | </html> |
@@ -2,6 +2,8 @@ | ||
2 | 2 | <% if current_author.artist? -%> |
3 | 3 | <%= form_tag( {:action => "create"} , { :multipart => true }) do %> |
4 | 4 | <label for="file">File to Upload</label> <%= file_field_tag "original_picture[file]" %> |
5 | + lisence | |
6 | + <%= collection_select :original_picture, :lisence_id, Lisence.all.map {|l| [l.name, l.id] }, :last, :first, :html => {:selected => current_author.artist.default_lisence_id} %> | |
5 | 7 | <%= submit_tag 'upload' -%> |
6 | 8 | <% end -%> |
7 | 9 | <% else -%> |
@@ -8,5 +8,6 @@ | ||
8 | 8 | <%= original_picture.width %>x<%= original_picture.height %> |
9 | 9 | <%= original_picture.filesize %>bytes |
10 | 10 | 画:<%= h original_picture.artist.name %> |
11 | + lisence:<%= h Lisence.find(original_picture.lisence_id || 1).name %> | |
11 | 12 | </div> |
12 | 13 | <% end %> |
@@ -1,7 +1,7 @@ | ||
1 | 1 | Pettanr::Application.routes.draw do |
2 | 2 | |
3 | 3 | devise_for :admins |
4 | - devise_for :authors | |
4 | + devise_for :authors, :controllers => { :registrations => "author_registrations" } | |
5 | 5 | |
6 | 6 | match 'original_pictures/:id(.:format)/refresh' => 'original_pictures#refresh' |
7 | 7 |
@@ -0,0 +1,5 @@ | ||
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe AuthorRegistrationsController do | |
4 | + | |
5 | +end |
@@ -0,0 +1,15 @@ | ||
1 | +require 'spec_helper' | |
2 | + | |
3 | +# Specs in this file have access to a helper object that includes | |
4 | +# the AuthorRegistrationsHelper. For example: | |
5 | +# | |
6 | +# describe AuthorRegistrationsHelper do | |
7 | +# describe "string concat" do | |
8 | +# it "concats two strings with spaces" do | |
9 | +# helper.concat_strings("this","that").should == "this that" | |
10 | +# end | |
11 | +# end | |
12 | +# end | |
13 | +describe AuthorRegistrationsHelper do | |
14 | + pending "add some examples to (or delete) #{__FILE__}" | |
15 | +end |