diff options
author | Rhenium <rhenium@rhe.jp> | 2013-12-18 13:04:04 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2013-12-18 13:04:04 +0900 |
commit | 9fad928924381e53d6bf542b226677fb1ecd9f2d (patch) | |
tree | 3f806850d34fd4a388ac3b48900db8ba8834b66a | |
parent | 3b6b25ad0551f6f8bc2dcc8a3e3a2e9db3356fe4 (diff) | |
download | aclog-9fad928924381e53d6bf542b226677fb1ecd9f2d.tar.gz |
update views
28 files changed, 71 insertions, 42 deletions
diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index b3af95d..77d6194 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -1,14 +1,11 @@ class AboutController < ApplicationController def index - @title = "aclog" render layout: "index" end def about - @title = "about" end def api - @title = "about api" end end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index b49006f..bf35c75 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -6,7 +6,6 @@ class ErrorsController < ApplicationController def render_error @exception = env["action_dispatch.exception"] - @title = "?" case @exception when OAuth::Unauthorized diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb index ca36718..3d74913 100644 --- a/app/controllers/tweets_controller.rb +++ b/app/controllers/tweets_controller.rb @@ -1,86 +1,78 @@ -# -*- encoding: utf-8 -*- class TweetsController < ApplicationController def show - @tweets = Tweet.where(id: params[:id]) - raise Aclog::Exceptions::TweetNotFound unless @tweets.first - @user = @tweets.first.user - @caption = "#{@user.screen_name}'s Tweet" + @tweet = Tweet.find(params[:id]) + @user = @tweet.user + rescue ActiveRecord::RecordNotFound + raise Aclog::Exceptions::TweetNotFound end - # only JSON API def lookup - ids = params[:id].to_s.split(",").map(&:to_i) - @tweets = Tweet.where(id: ids) - @caption = "Tweets" + @tweets = Tweet.where(id: params[:id].to_s.split(",").map(&:to_i)) end def index user_required - best rescue timeline + begin + best + rescue + timeline + render "timeline" + else + render "best" + end end def best user_required check_public! - @caption = "#{@user.screen_name}'s Best" @tweets = @user.tweets.list(params, force_page: true).reacted.order_by_reactions end def recent user_required check_public! - @caption = "#{@user.screen_name}'s Recent Best" @tweets = @user.tweets.list(params, force_page: true).recent.reacted.order_by_reactions end def timeline user_required - @caption = "#{@user.screen_name}'s Newest" @tweets = @user.tweets.list(params).reacted.order_by_id end def discoveries user_required - @caption = "#{@user.screen_name}'s Discoveries" @tweets = Tweet.list(params, force_page: true).discovered_by(@user).order_by_id end def favorites user_required - @caption = "#{@user.screen_name}'s Favorites" @tweets = Tweet.list(params, force_page: true).favorited_by(@user).order_by_id end def retweets user_required - @caption = "#{@user.screen_name}'s Retweets" @tweets = Tweet.list(params, force_page: true).retweeted_by(@user).order_by_id end def discovered_by user_required user_b_required - @caption = "Discovored by #{@user_b.screen_name}" @tweets = @user.tweets.list(params).discovered_by(@user_b).order_by_id end def all_best - @caption = "Top Tweets" @tweets = Tweet.list(params, force_page: true).reacted.order_by_reactions end def all_recent - @caption = "Recent" @tweets = Tweet.list(params, force_page: true).recent.reacted.order_by_reactions end def all_timeline - @caption = "Newest" @tweets = Tweet.list(params).reacted.order_by_id end def search - @caption = "Search" @tweets = Tweet.list(params, force_page: true).parse_query(params[:q].to_s || "").reacted.not_protected.order_by_id @tweets = @tweets.recent(7) unless @tweets.to_sql.include?("`tweets`.`id`") end @@ -99,18 +91,18 @@ class TweetsController < ApplicationController end def render(*args) - if request.xhr? - html = render_to_string(partial: "tweets/tweet", collection: @tweets.includes(:user), as: :tweet, formats: :html) + if @tweets && request.xhr? + html = render_to_string(partial: "tweet", collection: @tweets.includes(:user), as: :tweet, formats: :html) n = @tweets.length > 0 ? url_for(params[:page] ? params.merge(page: params[:page].to_i + 1) : params.merge(max_id: @tweets.last.id - 1)) : nil super json: {html: html, next: n} - elsif lookup_context.exists?(params[:action], params[:controller]) - super(*args) - else + elsif @tweets && !lookup_context.exists?(params[:action], params[:controller]) && request.format == :json super("_tweets") + else + super(*args) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 59123f0..96b2986 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -45,17 +45,16 @@ module ApplicationHelper end end - def caption - "#{@caption}" + def caption(text) + content_for :caption do + text + end end - def title - if @tweet - text = CGI.unescapeHTML(strip_tags(format_tweet_text(@tweet.text))) - @title = "\"#{text}\" from #{@user.screen_name}" + def title(*args) + content_for :title do + (args.compact + ["aclog"]).join(" - ") end - - "#{@title || @caption} - aclog" end # utf8, form diff --git a/app/views/about/about.html.haml b/app/views/about/about.html.haml index e9ae769..ec3f6db 100644 --- a/app/views/about/about.html.haml +++ b/app/views/about/about.html.haml @@ -1,3 +1,4 @@ +- title "about" %p Twitter API の UserStreams というものを使い、登録ユーザーのお気に入り登録・自分のツイートのお気に入り登録され・リツイート・リツイートされをリアルタイムで記録し、集計して表示することができるサービスです。 %p diff --git a/app/views/about/api.html.haml b/app/views/about/api.html.haml index 9e8882f..6097e1e 100644 --- a/app/views/about/api.html.haml +++ b/app/views/about/api.html.haml @@ -1,3 +1,4 @@ +- title "API" %p **ドキュメントは書き直します** %p diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml index ae346b9..0ad8d89 100644 --- a/app/views/about/index.html.haml +++ b/app/views/about/index.html.haml @@ -1,3 +1,4 @@ +- title nil .index.text-center %h1 aclog diff --git a/app/views/errors/render_error.html.haml b/app/views/errors/render_error.html.haml index 35eca43..210deed 100644 --- a/app/views/errors/render_error.html.haml +++ b/app/views/errors/render_error.html.haml @@ -1,3 +1,4 @@ +- title "Error" %h1= response.status .lead = @message diff --git a/app/views/help/search.html.haml b/app/views/help/search.html.haml index b4c50bd..1639ac1 100644 --- a/app/views/help/search.html.haml +++ b/app/views/help/search.html.haml @@ -1,3 +1,4 @@ +- title "Search Options" %h2 search options %table %tr diff --git a/app/views/layouts/_base.html.haml b/app/views/layouts/_base.html.haml index b8dc277..2364b50 100644 --- a/app/views/layouts/_base.html.haml +++ b/app/views/layouts/_base.html.haml @@ -1,7 +1,7 @@ !!! xml %html{xmlns: "http://www.w3.org/1999/xhtml"} %head - %title= title + %title= yield :title = stylesheet_link_tag "application", media: "all" = stylesheet_link_tag params[:controller], media: "all" = javascript_include_tag "application" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 47a77ac..f342955 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,5 +3,5 @@ .col-sm-3 .sidebar= render partial: "shared/sidebar/#{sidebar_type}" .col-sm-9 - %h1= caption + %h1= yield :caption = yield diff --git a/app/views/settings/confirm_deactivation.html.haml b/app/views/settings/confirm_deactivation.html.haml index bc58b74..0e4e846 100644 --- a/app/views/settings/confirm_deactivation.html.haml +++ b/app/views/settings/confirm_deactivation.html.haml @@ -1,3 +1,4 @@ +- title "Account Deactivation" %h1 deactivate = form_tag "/i/settings/deactivate", method: :post do = link_to "Cancel", action: "index" diff --git a/app/views/settings/deactivate.html.haml b/app/views/settings/deactivate.html.haml index 94d3203..7cf44d9 100644 --- a/app/views/settings/deactivate.html.haml +++ b/app/views/settings/deactivate.html.haml @@ -1,3 +1,4 @@ +- title "Account Deactivation" %h1 deactivated ご利用ありがとうございました。記録を停止されますが、データは削除されません。もう一度ログインをすると記録が再開されます。 diff --git a/app/views/settings/index.html.haml b/app/views/settings/index.html.haml index 22f631f..b128b58 100644 --- a/app/views/settings/index.html.haml +++ b/app/views/settings/index.html.haml @@ -1,3 +1,4 @@ +- title "Account Settings" %h1 settings = form_tag "/i/settings/update", method: :post do .checkbox diff --git a/app/views/tweets/all_best.html.haml b/app/views/tweets/all_best.html.haml new file mode 100644 index 0000000..a765c9d --- /dev/null +++ b/app/views/tweets/all_best.html.haml @@ -0,0 +1,3 @@ +- title "Top Tweets" +- caption :title +- render "tweets" diff --git a/app/views/tweets/all_recent.html.haml b/app/views/tweets/all_recent.html.haml new file mode 100644 index 0000000..6e85631 --- /dev/null +++ b/app/views/tweets/all_recent.html.haml @@ -0,0 +1,3 @@ +- title "Top Recent Tweets" +- caption :title +- render "tweets" diff --git a/app/views/tweets/all_timeline.html.haml b/app/views/tweets/all_timeline.html.haml new file mode 100644 index 0000000..27e137a --- /dev/null +++ b/app/views/tweets/all_timeline.html.haml @@ -0,0 +1,3 @@ +- title "Newest" +- caption :title +- render "tweets" diff --git a/app/views/tweets/best.html.haml b/app/views/tweets/best.html.haml new file mode 100644 index 0000000..6ca3ef4 --- /dev/null +++ b/app/views/tweets/best.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Best Tweets" +- caption :title +- render "tweets" diff --git a/app/views/tweets/discovered_by.html.haml b/app/views/tweets/discovered_by.html.haml new file mode 100644 index 0000000..b3323bd --- /dev/null +++ b/app/views/tweets/discovered_by.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Discovered by " + @user_b.screen_name +- caption :title +- render "tweets" diff --git a/app/views/tweets/discoveries.html.haml b/app/views/tweets/discoveries.html.haml new file mode 100644 index 0000000..cd2412f --- /dev/null +++ b/app/views/tweets/discoveries.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Discoveries" +- caption :title +- render "tweets" diff --git a/app/views/tweets/favorites.html.haml b/app/views/tweets/favorites.html.haml new file mode 100644 index 0000000..cd2412f --- /dev/null +++ b/app/views/tweets/favorites.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Discoveries" +- caption :title +- render "tweets" diff --git a/app/views/tweets/recent.html.haml b/app/views/tweets/recent.html.haml new file mode 100644 index 0000000..f024b7e --- /dev/null +++ b/app/views/tweets/recent.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Recent Best Tweets" +- caption :title +- render "tweets" diff --git a/app/views/tweets/retweets.html.haml b/app/views/tweets/retweets.html.haml new file mode 100644 index 0000000..cd2412f --- /dev/null +++ b/app/views/tweets/retweets.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Discoveries" +- caption :title +- render "tweets" diff --git a/app/views/tweets/search.html.haml b/app/views/tweets/search.html.haml index e01265b..5066822 100644 --- a/app/views/tweets/search.html.haml +++ b/app/views/tweets/search.html.haml @@ -1,3 +1,4 @@ +- title "Search" .search = form_tag({}, method: "get", class: "form-inline") do = field_set_tag do diff --git a/app/views/tweets/show.html.haml b/app/views/tweets/show.html.haml index 4ce481c..61a79d6 100644 --- a/app/views/tweets/show.html.haml +++ b/app/views/tweets/show.html.haml @@ -1 +1,3 @@ -.tweets= render @tweets +- title CGI.unescapeHTML(strip_tags(format_tweet_text(@tweet.text))) + " from @" + @user.screen_name +- caption @user.screen_name + "'s Tweet" +.tweets= render @tweet diff --git a/app/views/tweets/show.json.jbuilder b/app/views/tweets/show.json.jbuilder index e58cabf..c92aaa0 100644 --- a/app/views/tweets/show.json.jbuilder +++ b/app/views/tweets/show.json.jbuilder @@ -1 +1 @@ -json.partial! "tweet", tweet: @tweets.first +json.partial! "tweet", tweet: @tweet diff --git a/app/views/tweets/timeline.html.haml b/app/views/tweets/timeline.html.haml new file mode 100644 index 0000000..14a7068 --- /dev/null +++ b/app/views/tweets/timeline.html.haml @@ -0,0 +1,3 @@ +- title @user.screen_name + "'s Newest" +- caption :title +- render "tweets" diff --git a/app/views/users/stats.html.haml b/app/views/users/stats.html.haml index 6e6b685..b8469f6 100644 --- a/app/views/users/stats.html.haml +++ b/app/views/users/stats.html.haml @@ -1,3 +1,4 @@ +- title "Stats" .avatar = image_tag @user.profile_image_url_original, alt: @user.screen_name, width: 128, height: 128 %p profile |