metazilla 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c615ac46c3e656c14e6abeb9a9b42fdedfc3495d
4
- data.tar.gz: 56469a5358933b69a2dc68047641b8dd8581a8fb
3
+ metadata.gz: b73475d91bed1c7be91b5b4f04098e4fe29fba77
4
+ data.tar.gz: f98750b74d3174646714fee94e41699e4ec916c4
5
5
  SHA512:
6
- metadata.gz: 85dc9c95017e50243ec48ee35e8888a9953e5c29e68947c4e3942c6c2cc695426df48a6a8e41967bc9707846fbfd55df3de229ec25bb32a25b766167e4a6adb7
7
- data.tar.gz: d688b119d24165c5350a12adc32146955b049fe746d37a1e43bfc593cb7d6117fc3193f4a3fe8a177e5864748b497fd4d0d3c252ea8d1db34e12595fe3754644
6
+ metadata.gz: ce6e2680705523bad3777ef5e76c72f67c11e4c235ed54169a917722035278d2c651d05e42338554468f1f095cfb21089443ec82a35da0155235e7b548a7a2ab
7
+ data.tar.gz: 15179e16b9d06ea2dafa6b2a1794e21dbabdc2f99fefee92d0952dba4181bd2cf1c8f50d93ac67d2baff1d44b15f521f4d6ab7874b2433df1ba77669ab036620
data/README.md CHANGED
@@ -28,6 +28,16 @@ And then execute:
28
28
 
29
29
  `title_tag` generates `<title>` tag with full title. Place this in your layout.
30
30
 
31
+ #### Custom title separator
32
+
33
+ If you want your title tag content to look like this: `My Application > My cool page`, tell Metazilla to use custom separator.
34
+
35
+ config/initializers/metazilla.rb:
36
+
37
+ Metazilla.configure do |config|
38
+ config.separator = " > "
39
+ end
40
+
31
41
  ### Meta tags
32
42
 
33
43
  `meta :description, "My app description"` to set meta tag.
@@ -82,6 +92,18 @@ View:
82
92
 
83
93
  title # => User: John Doe
84
94
 
95
+ ### Action aliasing (:create and :update problem)
96
+
97
+ Metaziila uses name of the current action for resolving titles, so when you submit a form and it fails to save, your rendered `new` template inside the `create` action. To avoid setting duplicated titles for both `new` and `create` (and `edit` and `update`), this actions is mapped in gem's configuration.
98
+ If your application have similar non-RESTful pair of actions, your can add them to mapping:
99
+
100
+ config/initializers/metazilla.rb:
101
+
102
+ Metazilla.configure do |config|
103
+ config.mapping[:perform_parse] = :parse
104
+ end
105
+
106
+ Now you can define title only for `parse` action, `perform_parse` will use it automagically.
85
107
 
86
108
  ### Namespacing
87
109
 
@@ -13,7 +13,7 @@ module Metazilla
13
13
  end
14
14
 
15
15
  def lookup_for_current_path(key)
16
- lookup_recursively(key, [namespace, controller, action].flatten)
16
+ lookup_recursively(key, [namespace, controller, mapped_action].flatten)
17
17
  end
18
18
 
19
19
  private
@@ -35,6 +35,10 @@ module Metazilla
35
35
  nil
36
36
  end
37
37
 
38
+ def mapped_action
39
+ (Metazilla.configuration.mapping[action.to_sym] || action).to_s.freeze
40
+ end
41
+
38
42
  def lookup_in_namespace(key, namespace = [])
39
43
  t_key = [namespace, key].flatten.compact.join('.')
40
44
  i18n_set?(t_key) ? I18n.t(t_key, context) : nil
@@ -1,3 +1,3 @@
1
1
  module Metazilla
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -23,7 +23,7 @@ module Metazilla
23
23
  end
24
24
 
25
25
  def full_title
26
- [title, app_title].flatten.compact.join(" | ")
26
+ [title, app_title].flatten.compact.join(Metazilla.configuration.separator)
27
27
  end
28
28
 
29
29
  def meta(name, content = nil)
data/lib/metazilla.rb CHANGED
@@ -3,6 +3,26 @@ require "metazilla/version"
3
3
  require "metazilla/view_helper"
4
4
 
5
5
  module Metazilla
6
+ def self.configure
7
+ yield(configuration) if block_given?
8
+ end
9
+
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+
14
+ def self.reset_configuration
15
+ @configuration = Configuration.new
16
+ end
17
+
18
+ class Configuration
19
+ attr_accessor :separator, :mapping
20
+
21
+ def initialize
22
+ @separator = ' | '
23
+ @mapping = { create: :new, update: :edit }
24
+ end
25
+ end
6
26
  end
7
27
 
8
28
  ActionView::Base.send :include, Metazilla::ViewHelper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metazilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Likholetov