SUZUKI Miho
null+****@clear*****
Wed Sep 26 17:47:58 JST 2012
SUZUKI Miho 2012-09-26 17:47:58 +0900 (Wed, 26 Sep 2012) New Revision: d7c93d06491d3444c93b3cc1d3d1e28a12084b44 https://github.com/logaling/logaling-server/commit/d7c93d06491d3444c93b3cc1d3d1e28a12084b44 Merged ef3396d: Merge pull request #17 from logaling/apply-design Log: Apply desing to search page except pagination Modified files: app/helpers/search_helper.rb app/models/user_glossary.rb app/views/search/index.html.haml app/views/shared/_term.html.haml Modified: app/helpers/search_helper.rb (+3 -0) =================================================================== --- app/helpers/search_helper.rb 2012-09-26 15:49:43 +0900 (b3ce20a) +++ app/helpers/search_helper.rb 2012-09-26 17:47:58 +0900 (071f9e0) @@ -1,2 +1,5 @@ module SearchHelper + def github_project?(glossary_name) + glossary_name =~ /^github/ + end end Modified: app/models/user_glossary.rb (+12 -0) =================================================================== --- app/models/user_glossary.rb 2012-09-26 15:49:43 +0900 (846b6eb) +++ app/models/user_glossary.rb 2012-09-26 17:47:58 +0900 (cdfbd09) @@ -9,6 +9,18 @@ class UserGlossary < ActiveRecord::Base after_create :create_personal_project! + class << self + def find_by_term(term_hash, user) + conditions = {} + user_id, conditions[:name] = term_hash[:glossary_name].split("-", 2) + return nil if user.id != user_id.to_i + conditions[:source_language] = term_hash[:source_language] + conditions[:target_language] = term_hash[:target_language] + conditions[:user_id] = user.id + UserGlossary.find(:first, :conditions => conditions) + end + end + def glossary_name "%05d-%s" % [user_id, name] end Modified: app/views/search/index.html.haml (+16 -7) =================================================================== --- app/views/search/index.html.haml 2012-09-26 15:49:43 +0900 (b26f82e) +++ app/views/search/index.html.haml 2012-09-26 17:47:58 +0900 (664b325) @@ -1,7 +1,16 @@ -- if****@terms*****? - -****@terms***** do |term| - = render :partial => 'shared/term', :locals => {:term => term} -- else - .alert.alert-info - %strong Not found. - Try another query. +%div.container + %h1 + 検索結果 + - if****@terms*****? + %p + 1- + =****@terms***** + 件表示 / + =****@terms***** + 件中 + -****@terms***** do |term| + = render :partial => 'shared/term', :locals => {:term => term} + - else + %p + = @query + は見つかりませんでした。 Modified: app/views/shared/_term.html.haml (+26 -11) =================================================================== --- app/views/shared/_term.html.haml 2012-09-26 15:49:43 +0900 (ac4dbbd) +++ app/views/shared/_term.html.haml 2012-09-26 17:47:58 +0900 (560fee3) @@ -1,11 +1,26 @@ -.term.well - %span.source-language.label= term[:source_language] - %span.source-term= render_sinpped(term[:snipped_source_term]) - %span.target-language.label= term[:target_language] - %span.target-term= term[:target_term] - - if term[:note].present? - %i.icon-pencil - %span.note= term[:note] - .pull-right - %i.icon-folder-open - %span= term[:glossary_name] +.term + .row + .span9 + %span.label<> + = term[:source_language] + = render_sinpped(term[:snipped_source_term]) + %span.label<> + = term[:target_language] + = term[:target_term] + %i.icon-pencil + %span= term[:note] + .span2.property + - if github_project?(term[:glossary_name]) + %p.githubProject + = link_to term[:glossary_name], '#' + - else + - user_glossary = UserGlossary.find_by_term(term, current_user) + %p.logalingProject + = link_to term[:glossary_name], '#' + - if user_glossary + %p.btn-group.actions + %a.btn.btn-mini{ :href => '#', :title => '編集' } + %i.icon-pencil + %a.btn.btn-mini{ :href => '#', :title => '削除する' } + %i.icon-trash + -------------- next part -------------- An HTML attachment was scrubbed... ダウンロード