[logaling-commit] logaling/logaling-server [master] Change logaling name for github project

アーカイブの一覧に戻る

SHIMADA Koji null+****@clear*****
Mon Oct 8 13:53:18 JST 2012


SHIMADA Koji	2012-10-08 13:53:18 +0900 (Mon, 08 Oct 2012)

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

  Merged ea0e336: Merge pull request #28 from logaling/change-logalin-name-for-github-project

  Log:
    Change logaling name for github project
    
    use ':' as delimiter instead of '-'
    because owner/project name may contain '-'

  Modified files:
    app/helpers/application_helper.rb
    app/models/additional_information_as_search_results.rb
    app/models/github_project.rb

  Modified: app/helpers/application_helper.rb (+2 -2)
===================================================================
--- app/helpers/application_helper.rb    2012-10-08 13:27:20 +0900 (96700ac)
+++ app/helpers/application_helper.rb    2012-10-08 13:53:18 +0900 (5bb971a)
@@ -21,9 +21,9 @@ module ApplicationHelper
 
   def link_to_glossary_with(term)
     if term.github_project?
-      github_project_id = term.glossary_name_without_github.sub('-', '/')
+      github_project_id = term.glossary_name_without_github.sub(':', '/')
       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))
+      link_to(term.decorated_glossary_name, 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)

  Modified: app/models/additional_information_as_search_results.rb (+10 -3)
===================================================================
--- app/models/additional_information_as_search_results.rb    2012-10-08 13:27:20 +0900 (807f6ba)
+++ app/models/additional_information_as_search_results.rb    2012-10-08 13:53:18 +0900 (2dc1a41)
@@ -29,8 +29,15 @@ module AdditionalInformationAsSearchResults
   alias_method :glossary_name_without_github, :glossary_name_without_user_id
 
   def decorated_glossary_name
-    user_id, glossary_name = split_glossary_name_to_user_id_and_name
-    name = User.where(id: user_id.to_i).first.name
-    "#{name}-#{glossary_name}"
+    if github_project?
+      owner_name, project_name = glossary_name_without_github.split(":", 2)
+      "#{owner_name}-#{project_name}"
+    elsif user_glossary?
+      user_id, glossary_name = split_glossary_name_to_user_id_and_name
+      name = User.where(id: user_id.to_i).first.name
+      "#{name}-#{glossary_name}"
+    else
+      glossary_name
+    end
   end
 end

  Modified: app/models/github_project.rb (+1 -1)
===================================================================
--- app/models/github_project.rb    2012-10-08 13:27:20 +0900 (9d5b8b8)
+++ app/models/github_project.rb    2012-10-08 13:53:18 +0900 (68431bd)
@@ -38,7 +38,7 @@ class GithubProject < ActiveRecord::Base
 
   # project name for logaling
   def logaling_name
-    "github-%s-%s" % [owner, name]
+    "github-%s:%s" % [owner, name]
   end
 
   def glossaries
-------------- next part --------------
An HTML attachment was scrubbed...
ダウンロード 



More information about the logaling-commit mailing list
アーカイブの一覧に戻る