jap_mag 1.3.4 → 1.4.1

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
  SHA256:
3
- metadata.gz: e28dda46d885cb454f61326fc907e27931c9cf7cdad5e189597692ce364141c5
4
- data.tar.gz: 47babaf33cba04d636228888e5f11045be461a0d2253e1740c3c6ed8790c5fdb
3
+ metadata.gz: da4291c0e51485cbd7930abcb87681d0199e9d6c9b29bc018c0106e2a139d1ad
4
+ data.tar.gz: 5a4221ac9985205c43e3bf865a69479caedc39585cc2a1e8b5821c7e8f8f3313
5
5
  SHA512:
6
- metadata.gz: 96d782db55135d0eed4615174d6f92802d7b7c3dbd5a5f0cf347d8a77c6237fc4b3a77ff9405fee0d04a7250ac4879f3fa0539d35d5ca9d667760ea794c18bac
7
- data.tar.gz: 238aa199bc5dc8bc35336f698281b2ea3660f9b85200aa7ba0dda0936f169174beec901891f6b69fcae265762bfa73cc5d1e179fe891812477cb2df819a1b0e1
6
+ metadata.gz: c8b2ebc29ed3f0608c5999734d19acf75d569556c108ea51c8e862385feaf1ee88102b7f51110d6b415a7c96ad1974bd02667a01f457b722043fc3579692c8ad
7
+ data.tar.gz: 349e465646d784975897c80ceca45098fa2f754ad68db13cbe5652a85495b8a316b40b201a060febee70627955d5f668f3f5295664a50666d1ddaef582760d30
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.1.2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  JapMag is a collection of frequently-used Rails controller methods, helpers, Javascript functions and SASS mixins. It helps quickly bootstrap a Rails app.
4
4
 
5
- For example, [current_controller_action_in?](https://github.com/felixding/JapMag/blob/master/lib/jap_mag.rb#L38) is a helper that checks if current request.controller and request.action match with a set of given rules. You can then for example show or hide certain things on your app depending if it matches or not.
5
+ For example, [current_controller_action_in?](https://github.com/felixding/JapMag/blob/master/lib/jap_mag.rb#L38) is a helper that checks if current request.controller and request.action match with a set of given rules. You can then for example show or hide certain things on your app depending if it matches or not.
6
6
 
7
7
  Another example is [retina_image_tag](https://github.com/felixding/JapMag/blob/master/app/helpers/jap_mag_widgets_helper.rb#L164) which can easily generate HTML `img` tags for Retina/Non-retina screens. It also helps you deal with localized images.
8
8
 
@@ -10,7 +10,7 @@ This project was first created in 2012.
10
10
 
11
11
  ## Installation & Usage
12
12
 
13
- Please note JapMag only supports Rails 3+.
13
+ Please note JapMag only supports Rails 3+. And starting from v1.4.0, Ruby 3.0+ is required.
14
14
 
15
15
  Add this line to your application's Gemfile:
16
16
 
@@ -190,6 +190,20 @@ module JapMagWidgetsHelper
190
190
  image_tag name_at_1x, options
191
191
  end
192
192
 
193
+ def section_t key, opts = {}
194
+ I18n.t "#{params[:controller]}.#{params[:action]}.sections.#{key}", **opts
195
+ end
196
+
197
+ def render_sections *args, **opts
198
+ opts = {locals: {}}.merge(opts)
199
+
200
+ args.collect do |section|
201
+ tpl = "#{params[:controller].gsub('#', '/')}/#{params[:action]}/#{section}"
202
+
203
+ render partial: tpl, locals: opts[:locals]
204
+ end.join.html_safe
205
+ end
206
+
193
207
  protected
194
208
 
195
209
  def current_template
@@ -1,3 +1,3 @@
1
1
  module JapMag
2
- VERSION = "1.3.4"
2
+ VERSION = "1.4.1"
3
3
  end
data/lib/jap_mag.rb CHANGED
@@ -43,29 +43,15 @@ module JapMag
43
43
  # multiple arguments: "page#index", "page#intro"
44
44
  #
45
45
  def current_controller_action_in?(*args)
46
- controller = params["controller"]
47
- action = params["action"]
46
+ controller = params[:controller]
47
+ action = params[:action]
48
+ #raise args.inspect if args != 'homepage/page#index'
48
49
 
49
- if args.size == 1
50
- if args.first.is_a?(Array)
51
- arguments = args.first.split(" ").first
52
- elsif args.first.is_a?(String)
53
- if args.first.split(" ").size > 1
54
- arguments = args.first.split(" ")
55
- else
56
- arguments = args
57
- end
58
- end
59
- else
60
- arguments = args
61
- end
62
-
63
- #raise arguments.inspect
50
+ args = args.first if args.size == 1 && args.first.is_a?(Array)
64
51
 
65
- arguments.each do |element|
66
- if element.include?("#")
67
- array = element.match(/([a-z\-\_\/]*)#([a-z\-\_]*)/).to_a
68
- c, a = array[1], array[2]
52
+ args.each do |element|
53
+ if element.to_s.include?("#")
54
+ c, a = element.split('#')
69
55
  return true if controller == c && action == a
70
56
  else
71
57
  return true if controller == element
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jap_mag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DING Yu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-17 00:00:00.000000000 Z
11
+ date: 2022-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".gitignore"
36
+ - ".ruby-version"
36
37
  - Gemfile
37
38
  - README.md
38
39
  - Rakefile
@@ -57,7 +58,7 @@ files:
57
58
  homepage: https://github.com/felixding/JapMag
58
59
  licenses: []
59
60
  metadata: {}
60
- post_install_message:
61
+ post_install_message:
61
62
  rdoc_options: []
62
63
  require_paths:
63
64
  - lib
@@ -72,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
- rubygems_version: 3.3.11
76
- signing_key:
76
+ rubygems_version: 3.3.5
77
+ signing_key:
77
78
  specification_version: 4
78
79
  summary: jap_mag-
79
80
  test_files: []