[logaling-commit] logaling/logaling-server [master] Add link to glossary from search result

Back to archive index

SHIMADA Koji null+****@clear*****
Mon Oct 8 11:42:19 JST 2012


SHIMADA Koji	2012-10-08 11:42:19 +0900 (Mon, 08 Oct 2012)

  New Revision: c5ae42ce8fc82c32e6ad05b8d6a1466a3fdbe4a2
  https://github.com/logaling/logaling-server/commit/c5ae42ce8fc82c32e6ad05b8d6a1466a3fdbe4a2

  Merged 7321e38: Merge pull request #26 from logaling/improve-glossary-uri

  Log:
    Add link to glossary from search result

  Modified files:
    app/helpers/application_helper.rb
    app/views/shared/_term.html.haml

  Modified: app/helpers/application_helper.rb (+12 -0)
===================================================================
--- app/helpers/application_helper.rb    2012-10-08 11:13:29 +0900 (f23f5ec)
+++ app/helpers/application_helper.rb    2012-10-08 11:42:19 +0900 (c670340)
@@ -18,4 +18,16 @@ module ApplicationHelper
   def count_of_end_position(per_count, current_page, page_count)
     per_count * (current_page - 1) + page_count
   end
+
+  def link_to_glossary_with(term)
+    if term.github_project?
+      github_project_id = term.glossary_name_without_github.gsub('-', '/')
+      bilingual_pair = [term.source_language, term.target_language].join('-')
+      link_to(term.glossary_name_without_github, github_project_glossary_path(id: bilingual_pair, github_project_id: github_project_id))
+    elsif term.user_glossary?
+      owner = User.find(term.split_glossary_name_to_user_id_and_name[0])
+      user_glossary = UserGlossary.find_by_term_and_user(term, owner)
+      link_to(term.decorated_glossary_name, user_glossary_path(owner, user_glossary))
+    end
+  end
 end

  Modified: app/views/shared/_term.html.haml (+2 -2)
===================================================================
--- app/views/shared/_term.html.haml    2012-10-08 11:13:29 +0900 (1329bab)
+++ app/views/shared/_term.html.haml    2012-10-08 11:42:19 +0900 (9d9c82f)
@@ -14,10 +14,10 @@
     .span2.property
       - if term.github_project?
         %p.githubProject
-          = link_to term.glossary_name_without_github, '#'
+          = link_to_glossary_with(term)
       - elsif term.user_glossary?
         %p.logalingProject
-          = link_to term.decorated_glossary_name, '#'
+          = link_to_glossary_with(term)
           - if signed_in?
             - user_glossary = UserGlossary.find_by_term_and_user(term, current_user)
             - if user_glossary
-------------- next part --------------
An HTML attachment was scrubbed...
下載 



More information about the logaling-commit mailing list
Back to archive index