karakuri-bao 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -3
- data/lib/karakuri.rb +15 -5
- metadata +22 -38
data/README.md
CHANGED
@@ -37,6 +37,13 @@ For example, to use seo friendly titles, your layout.rhtml should be looking lik
|
|
37
37
|
.
|
38
38
|
.
|
39
39
|
|
40
|
+
**TIPS**: To have a customized title separator, put this in your `config.ru`
|
41
|
+
|
42
|
+
require 'karakuri'
|
43
|
+
|
44
|
+
Karakuri.title_separator = '+'
|
45
|
+
|
46
|
+
|
40
47
|
### Tags
|
41
48
|
Adding the tagging feature requires the _toto_prerelease_ as mentioned above, since we need the http request to apply our little hack.
|
42
49
|
|
@@ -66,9 +73,16 @@ Next, you need a place to show the tag links, for example the index.rhtml:
|
|
66
73
|
.
|
67
74
|
.
|
68
75
|
|
76
|
+
**TIPS**: Again, to customize your tag link format, put this in your `config.ru`:
|
77
|
+
|
78
|
+
require 'karakuri'
|
79
|
+
|
80
|
+
Karakuri.link_format = '<a href="/tagged?tag={tag}" title="your customed title">{tag}</a> '
|
81
|
+
|
82
|
+
`{tag}` (keep it as it is in your `config.ru`) will be the placeholder for your tag corresponding to each article and is required.
|
69
83
|
|
70
84
|
|
71
|
-
And again: piece of cake ;-). Now all we need to add is a page that displays articles belonging to a
|
85
|
+
And again: piece of cake ;-). Now all we need to add is a page that displays articles belonging to a certain tag:
|
72
86
|
|
73
87
|
Create a page called `tagged.rhtml` in your `templates/pages` directory that looks like this:
|
74
88
|
|
@@ -82,7 +96,7 @@ Create a page called `tagged.rhtml` in your `templates/pages` directory that loo
|
|
82
96
|
|
83
97
|
<% Karakuri::desired_articles(@articles, desired_tag).each do |article| %>
|
84
98
|
<li>
|
85
|
-
<span class="descr"><a href="<%= article.path %>"
|
99
|
+
<span class="descr"><a href="<%= article.path %>" title="<%= article.title %>"><%= article.title %></a><br/></span>
|
86
100
|
</li>
|
87
101
|
<% end %>
|
88
102
|
</ul>
|
@@ -103,7 +117,7 @@ Thanks [baopham](https://github.com/baopham) for the nice addition.
|
|
103
117
|
|
104
118
|
### short url (via bit.ly)
|
105
119
|
|
106
|
-
To use a bit.ly shortened URL, just call the
|
120
|
+
To use a bit.ly shortened URL, just call the following function inside a .rhtml file:
|
107
121
|
|
108
122
|
<%= Karakuri::short_url_bitly(<url>, <bit.ly login name>, <bit.ly api key>) %>
|
109
123
|
|
data/lib/karakuri.rb
CHANGED
@@ -6,6 +6,16 @@ require 'uri'
|
|
6
6
|
# Some useful feature for toto and the likes. Basically, any ruby based blog or site.
|
7
7
|
#
|
8
8
|
module Karakuri
|
9
|
+
@link_format = '<a href="/tagged?tag={tag}" title="articles concerning {tag}">{tag}</a> '
|
10
|
+
@title_separator = '|'
|
11
|
+
|
12
|
+
def self.link_format(format)
|
13
|
+
@link_format = format
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.title_separator(separator)
|
17
|
+
@title_separator = separator
|
18
|
+
end
|
9
19
|
#
|
10
20
|
# create a list of links to tagged articles, default link_format: <code>%&<a href="/tagged?tag=#{tag}" title="articles concerning #{tag}" >#{tag}</a> &</code>
|
11
21
|
#
|
@@ -14,8 +24,7 @@ module Karakuri
|
|
14
24
|
tag_list = csv_to_array(csv_string)
|
15
25
|
if tag_list
|
16
26
|
tag_string = ""
|
17
|
-
|
18
|
-
tag_list.each { |tag| tag_string << %&<a href="/tagged?tag=#{tag}" title="articles concerning #{tag}" >#{tag}</a> & }
|
27
|
+
tag_list.each { |tag| tag_string << @link_format.gsub('{tag}', tag) }
|
19
28
|
end
|
20
29
|
tag_string
|
21
30
|
end
|
@@ -31,13 +40,12 @@ module Karakuri
|
|
31
40
|
# example for toto: <code>seo_friendly_title(@path, title, "mysite.com") will produce 'subpage | mysite.com' as seo friendly page title.</code>
|
32
41
|
#
|
33
42
|
def Karakuri.seo_friendly_title(path, title, seo_ending)
|
34
|
-
#TODO use custom title separator...
|
35
43
|
if path == 'index'
|
36
44
|
page_title = seo_ending
|
37
45
|
elsif path.split('/').compact.length == 4
|
38
|
-
page_title = title << "
|
46
|
+
page_title = title << " #{@title_separator} #{seo_ending}"
|
39
47
|
else
|
40
|
-
page_title = path.capitalize.gsub(/[-]/, ' ') << "
|
48
|
+
page_title = path.capitalize.gsub(/[-]/, ' ') << " #{@title_separator} #{seo_ending}"
|
41
49
|
end
|
42
50
|
page_title
|
43
51
|
end
|
@@ -127,3 +135,5 @@ module Karakuri
|
|
127
135
|
|
128
136
|
end
|
129
137
|
|
138
|
+
|
139
|
+
|
metadata
CHANGED
@@ -1,67 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: karakuri-bao
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 4
|
9
|
-
version: 0.1.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Bao Pham
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2012-04-11 00:00:00 -07:00
|
18
|
-
default_executable:
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: Some handy helpers for toto and the likes...
|
22
15
|
email: gbaopham@gmail.com
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
28
19
|
- README.md
|
29
20
|
- LICENSE
|
30
|
-
files:
|
21
|
+
files:
|
31
22
|
- LICENSE
|
32
23
|
- README.md
|
33
24
|
- Rakefile
|
34
25
|
- lib/karakuri.rb
|
35
26
|
- lib/serious_blog_helper.rb
|
36
|
-
has_rdoc: true
|
37
27
|
homepage: http://github.com/baopham/karakuri
|
38
28
|
licenses: []
|
39
|
-
|
40
29
|
post_install_message:
|
41
30
|
rdoc_options: []
|
42
|
-
|
43
|
-
require_paths:
|
31
|
+
require_paths:
|
44
32
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
59
45
|
requirements: []
|
60
|
-
|
61
46
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
47
|
+
rubygems_version: 1.8.15
|
63
48
|
signing_key:
|
64
49
|
specification_version: 3
|
65
50
|
summary: Some handy helpers for toto and the likes...
|
66
51
|
test_files: []
|
67
|
-
|