[Groonga-commit] ranguba/ranguba at e9c79e2 [master] Support customizing header/footer without replacing version controlled files

Back to archive index
Kouhei Sutou null+****@clear*****
Thu Oct 25 12:36:03 JST 2018


Kouhei Sutou	2018-10-25 12:36:03 +0900 (Thu, 25 Oct 2018)

  Revision: e9c79e25e8260bd8a69de306196bb607db8d2194
  https://github.com/ranguba/ranguba/commit/e9c79e25e8260bd8a69de306196bb607db8d2194

  Message:
    Support customizing header/footer without replacing version controlled files

  Modified files:
    lib/ranguba/template.rb
  Renamed files:
    config/customize/templates/footer.txt.sample
      (from config/customize/templates/footer.txt)
    config/customize/templates/header.txt.sample
      (from config/customize/templates/header.txt)
    config/customize/templates/title.txt.sample
      (from config/customize/templates/title.txt)

  Renamed: config/customize/templates/footer.txt.sample (+0 -0) 100%
===================================================================

  Renamed: config/customize/templates/header.txt.sample (+0 -0) 100%
===================================================================

  Renamed: config/customize/templates/title.txt.sample (+0 -0) 100%
===================================================================

  Modified: lib/ranguba/template.rb (+9 -3)
===================================================================
--- lib/ranguba/template.rb    2018-10-25 11:52:28 +0900 (d837851)
+++ lib/ranguba/template.rb    2018-10-25 12:36:03 +0900 (f4ac793)
@@ -2,9 +2,9 @@ class Ranguba::Template
   def initialize(encodings=nil)
     @encodings = encodings || default_encodings
     @base = Ranguba::Application.config.customize_base_path + 'templates'
-    @title_path = @base + 'title.txt'
-    @header_path = @base + 'header.txt'
-    @footer_path = @base + 'footer.txt'
+    @title_path = build_path('title.txt')
+    @header_path = build_path('header.txt')
+    @footer_path = build_path('footer.txt')
   end
 
   def title
@@ -27,4 +27,10 @@ class Ranguba::Template
       'footer.txt' => Encoding::UTF_8,
     }
   end
+
+  def build_path(path)
+    full_path = @base + path
+    return full_path if full_path.exist?
+    @base + "#{path}.sample"
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181025/c9d1c931/attachment.html>


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