symbolink 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +14 -2
- data/lib/symbolink.rb +13 -0
- data/lib/symbolink/configuration.rb +55 -0
- data/lib/symbolink/helper.rb +16 -23
- data/lib/symbolink/version.rb +1 -1
- data/test/dummy/app/views/users/edit.html.erb +1 -1
- data/test/dummy/app/views/users/new.html.erb +1 -1
- data/test/dummy/app/views/users/show.html.erb +1 -1
- data/test/dummy/config/initializers/symbolink.rb +5 -2
- data/test/dummy/log/development.log +51 -0
- data/test/dummy/log/test.log +37 -0
- data/test/dummy/tmp/pids/server.pid +1 -1
- metadata +9 -8
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -35,8 +35,20 @@ Symbolink maps ruby symbols to fragmetns of HTML code. The following symbols are
|
|
35
35
|
|
36
36
|
Add initializer to define custom symbols or override existing:
|
37
37
|
|
38
|
-
Symbolink.
|
39
|
-
|
38
|
+
Symbolink.configure do |config|
|
39
|
+
config.add_icons leader: '♛',
|
40
|
+
employee: '♙'
|
41
|
+
end
|
42
|
+
|
43
|
+
## Define actions
|
44
|
+
|
45
|
+
Action is a combination of icon + title. Actions may be defined as following:
|
46
|
+
|
47
|
+
Symbolink.configure do |config|
|
48
|
+
config.action :create, icon: :add, title: 'Create something'
|
49
|
+
end
|
50
|
+
|
51
|
+
So symbolink_to(:create, model) will returns the link with icon defined as :add and title 'Create something'.
|
40
52
|
|
41
53
|
|
42
54
|
|
data/lib/symbolink.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
require 'symbolink/helper'
|
2
2
|
require 'symbolink/engine'
|
3
|
+
require 'symbolink/configuration'
|
3
4
|
|
4
5
|
module Symbolink
|
6
|
+
def self.configuration
|
7
|
+
@configuration ||= Symbolink::Configuration.new
|
8
|
+
end
|
9
|
+
|
10
|
+
# @deprected use Symbolink.confiburation.add_icons instead
|
11
|
+
def self.add_symbols(map = {})
|
12
|
+
configuration.add_icons(map)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
yield configuration if block_given?
|
17
|
+
end
|
5
18
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Symbolink
|
2
|
+
class Configuration
|
3
|
+
attr_reader :symbols
|
4
|
+
attr_reader :actions
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@symbols, @actions = {}, {}
|
8
|
+
@symbols.default_proc = ->(hash, key) { raise ArgumentError, "Unregistered symbolink #{key}" }
|
9
|
+
init_defaults
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_icons(map = {})
|
13
|
+
map.each { |symbol, icon| @symbols[symbol] = icon.html_safe }
|
14
|
+
end
|
15
|
+
|
16
|
+
alias :add_icon :add_icons
|
17
|
+
alias :icon :add_icons
|
18
|
+
|
19
|
+
# Define action for symbol
|
20
|
+
# Options:
|
21
|
+
#
|
22
|
+
# - icon: symbol for defined icon or string.
|
23
|
+
# defies new icon with action name as a key if string given as icon
|
24
|
+
# uses action sysmbol as icon symbol if not provided
|
25
|
+
#
|
26
|
+
# - title: string to be used as link title
|
27
|
+
# humanized action sysmbol will be used as a title if not provided
|
28
|
+
def action(sym, ops = {})
|
29
|
+
ops[:icon] ||= sym
|
30
|
+
ops[:title] ||= sym.to_s.humanize
|
31
|
+
if ops[:icon].is_a?(String)
|
32
|
+
add_icon sym => ops[:icon]
|
33
|
+
ops[:icon] = sym
|
34
|
+
end
|
35
|
+
@actions[sym] = ops
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def init_defaults
|
41
|
+
add_icons(
|
42
|
+
delete: '✖',
|
43
|
+
add: '✚',
|
44
|
+
print: '⌸',
|
45
|
+
half: '½',
|
46
|
+
left_arrow: '≪',
|
47
|
+
double_left_arrow: '⋘',
|
48
|
+
right_arrow: '≫',
|
49
|
+
double_right_arrow: '⋙',
|
50
|
+
edit: '⌨',
|
51
|
+
refresh: '⟲',
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/symbolink/helper.rb
CHANGED
@@ -1,32 +1,25 @@
|
|
1
1
|
module Symbolink
|
2
|
-
SYMBOLS = {}
|
3
|
-
|
4
|
-
def self.add_symbols(map = {})
|
5
|
-
map.each { |symbol, icon| SYMBOLS[symbol] = icon.html_safe }
|
6
|
-
end
|
7
|
-
|
8
|
-
add_symbols(
|
9
|
-
delete: '✖',
|
10
|
-
add: '✚',
|
11
|
-
print: '⌸',
|
12
|
-
half: '½',
|
13
|
-
left_arrow: '≪',
|
14
|
-
double_left_arrow: '⋘',
|
15
|
-
right_arrow: '≫',
|
16
|
-
double_right_arrow: '⋙',
|
17
|
-
edit: '⌨',
|
18
|
-
refresh: '⟲',
|
19
|
-
)
|
20
|
-
|
21
|
-
SYMBOLS.default_proc = ->(hash, key) { raise ArgumentError, "Unregistered symbolink #{key}" }
|
22
|
-
|
23
2
|
module SymbolinkHelpers
|
3
|
+
def symbolicon(sym)
|
4
|
+
Symbolink.configuration.symbols[sym]
|
5
|
+
end
|
6
|
+
|
7
|
+
# @deprecate use symbolicon
|
24
8
|
def symbol(sym)
|
25
|
-
|
9
|
+
symbolicon(sym)
|
26
10
|
end
|
27
11
|
|
28
12
|
def symbolink_to(sym, options = {}, html_options = {})
|
29
|
-
|
13
|
+
action = Symbolink.configuration.actions[sym]
|
14
|
+
if action
|
15
|
+
icon = action[:icon]
|
16
|
+
title = action[:title]
|
17
|
+
else
|
18
|
+
icon = sym
|
19
|
+
title = sym.to_s.humanize
|
20
|
+
end
|
21
|
+
html_options[:title] ||= title
|
22
|
+
link_to(symbolicon(icon), options, html_options)
|
30
23
|
end
|
31
24
|
|
32
25
|
def symbolink_destroy(options = {}, html_options = {})
|
data/lib/symbolink/version.rb
CHANGED
@@ -505,3 +505,54 @@ Connecting to database specified by database.yml
|
|
505
505
|
[1m[36m (6.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
506
506
|
[1m[35m (0.0ms)[0m SELECT version FROM "schema_migrations"
|
507
507
|
[1m[36m (7.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20130124123012')[0m
|
508
|
+
|
509
|
+
|
510
|
+
Started GET "/" for 127.0.0.1 at 2013-02-06 17:19:16 +0400
|
511
|
+
Connecting to database specified by database.yml
|
512
|
+
Processing by UsersController#index as HTML
|
513
|
+
[1m[36mUser Load (0.0ms)[0m [1mSELECT "users".* FROM "users" [0m
|
514
|
+
Rendered users/index.html.erb within layouts/application (47.0ms)
|
515
|
+
Completed 200 OK in 627ms (Views: 476.0ms | ActiveRecord: 32.0ms)
|
516
|
+
|
517
|
+
|
518
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
519
|
+
Served asset /application.css - 200 OK (10ms)
|
520
|
+
|
521
|
+
|
522
|
+
Started GET "/assets/scaffold.css?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
523
|
+
Served asset /scaffold.css - 200 OK (3ms)
|
524
|
+
|
525
|
+
|
526
|
+
Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
527
|
+
Served asset /users.css - 200 OK (3ms)
|
528
|
+
|
529
|
+
|
530
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
531
|
+
Served asset /jquery.js - 200 OK (5ms)
|
532
|
+
|
533
|
+
|
534
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
535
|
+
Served asset /jquery_ujs.js - 200 OK (3ms)
|
536
|
+
|
537
|
+
|
538
|
+
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
539
|
+
Served asset /users.js - 200 OK (2ms)
|
540
|
+
|
541
|
+
|
542
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-02-06 17:19:18 +0400
|
543
|
+
Served asset /application.js - 200 OK (7ms)
|
544
|
+
|
545
|
+
|
546
|
+
Started GET "/users/2" for 127.0.0.1 at 2013-02-06 17:19:42 +0400
|
547
|
+
Processing by UsersController#show as HTML
|
548
|
+
Parameters: {"id"=>"2"}
|
549
|
+
[1m[35mUser Load (1.0ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", "2"]]
|
550
|
+
Rendered users/show.html.erb within layouts/application (1.0ms)
|
551
|
+
Completed 200 OK in 14ms (Views: 12.0ms | ActiveRecord: 1.0ms)
|
552
|
+
|
553
|
+
|
554
|
+
Started GET "/users" for 127.0.0.1 at 2013-02-06 17:20:25 +0400
|
555
|
+
Processing by UsersController#index as HTML
|
556
|
+
[1m[36mUser Load (1.0ms)[0m [1mSELECT "users".* FROM "users" [0m
|
557
|
+
Rendered users/index.html.erb within layouts/application (2.0ms)
|
558
|
+
Completed 200 OK in 12ms (Views: 11.0ms | ActiveRecord: 1.0ms)
|
data/test/dummy/log/test.log
CHANGED
@@ -198,3 +198,40 @@ Connecting to database specified by database.yml
|
|
198
198
|
Connecting to database specified by database.yml
|
199
199
|
Connecting to database specified by database.yml
|
200
200
|
Connecting to database specified by database.yml
|
201
|
+
Connecting to database specified by database.yml
|
202
|
+
Connecting to database specified by database.yml
|
203
|
+
Connecting to database specified by database.yml
|
204
|
+
Connecting to database specified by database.yml
|
205
|
+
Connecting to database specified by database.yml
|
206
|
+
Connecting to database specified by database.yml
|
207
|
+
Connecting to database specified by database.yml
|
208
|
+
Connecting to database specified by database.yml
|
209
|
+
Connecting to database specified by database.yml
|
210
|
+
Connecting to database specified by database.yml
|
211
|
+
Connecting to database specified by database.yml
|
212
|
+
Connecting to database specified by database.yml
|
213
|
+
Connecting to database specified by database.yml
|
214
|
+
Connecting to database specified by database.yml
|
215
|
+
Connecting to database specified by database.yml
|
216
|
+
Connecting to database specified by database.yml
|
217
|
+
Connecting to database specified by database.yml
|
218
|
+
Connecting to database specified by database.yml
|
219
|
+
Connecting to database specified by database.yml
|
220
|
+
Connecting to database specified by database.yml
|
221
|
+
Connecting to database specified by database.yml
|
222
|
+
Connecting to database specified by database.yml
|
223
|
+
Connecting to database specified by database.yml
|
224
|
+
Connecting to database specified by database.yml
|
225
|
+
Connecting to database specified by database.yml
|
226
|
+
Connecting to database specified by database.yml
|
227
|
+
Connecting to database specified by database.yml
|
228
|
+
Connecting to database specified by database.yml
|
229
|
+
Connecting to database specified by database.yml
|
230
|
+
Connecting to database specified by database.yml
|
231
|
+
Connecting to database specified by database.yml
|
232
|
+
Connecting to database specified by database.yml
|
233
|
+
Connecting to database specified by database.yml
|
234
|
+
Connecting to database specified by database.yml
|
235
|
+
Connecting to database specified by database.yml
|
236
|
+
Connecting to database specified by database.yml
|
237
|
+
Connecting to database specified by database.yml
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
25620
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbolink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &25153488 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.11
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *25153488
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &25152960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *25152960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &25152420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.12.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *25152420
|
47
47
|
description: Allow to register unicode symbols and displays them as symbolic icons
|
48
48
|
in rails application. Provides some helpers to generate the links by symbols.
|
49
49
|
email:
|
@@ -52,6 +52,7 @@ executables: []
|
|
52
52
|
extensions: []
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
|
+
- lib/symbolink/configuration.rb
|
55
56
|
- lib/symbolink/engine.rb
|
56
57
|
- lib/symbolink/helper.rb
|
57
58
|
- lib/symbolink/version.rb
|