simple_hashtag 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -4
- data/lib/generators/simple_hashtag/templates/views/hashtags_controller.rb +4 -0
- data/lib/generators/simple_hashtag/templates/views/hashtags_index.html.erb +5 -7
- data/lib/generators/simple_hashtag/templates/views/hashtags_show.html.erb +8 -0
- data/lib/generators/simple_hashtag/views_generator.rb +4 -0
- data/lib/simple_hashtag/version.rb +1 -1
- metadata +3 -3
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98a7fc288581be35b953cd9a69648e221ddc17b
|
4
|
+
data.tar.gz: 66215811d045e8c74a2700f0fc1eb18c067e143d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db17a33e4af18dba5cd3f37d0bc3ecb5111b0d14746e757cc5685872bfad4e6b0ae87506046deb2cb2bac0abd38a99c0a26405b76485347a93d03afa0e9e845b
|
7
|
+
data.tar.gz: 44e0ebbc7adbb16ea093a2324f6f31ff7356fab7e1e5a57e1e0aa4a23965f247b081c7403ab372febb2523dd368496268324c20931010a720b750197da36b9b3
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# SimpleHashtag
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/simple_hashtag.png)](http://badge.fury.io/rb/simple_hashtag)
|
4
|
+
|
3
5
|
Ruby gem for Rails that parses, stores, retreives and formats hashtags in your model.
|
4
6
|
|
5
7
|
_Simple Hashtag_ is a mix between–well–hashtags, as we know them, and categories.
|
@@ -71,18 +73,33 @@ Helpers are also available to create a link when displaying the text.
|
|
71
73
|
|
72
74
|
### Controller and Views
|
73
75
|
If you don't want to bother looking at the genrerated controller and views, here is a quick peek.
|
74
|
-
In a Controller, search for a Hashtag
|
76
|
+
In a Controller, display all hashtags, or search for a Hashtag and its associated records:
|
75
77
|
```ruby
|
76
78
|
class HashtagsController < ApplicationController
|
77
79
|
def index
|
80
|
+
@hashtags = SimpleHashtag::Hashtag.all
|
81
|
+
end
|
82
|
+
|
83
|
+
def show
|
78
84
|
@hashtag = SimpleHashtag::Hashtag.find_by_name(params[:hashtag])
|
79
85
|
@hashtagged = @hashtag.hashtaggables if @hashtag
|
80
86
|
end
|
81
87
|
end
|
82
88
|
```
|
83
89
|
|
90
|
+
The views could resemble something like this:
|
91
|
+
|
92
|
+
Index:
|
93
|
+
```erb
|
94
|
+
<h1>Hashtags</h1>
|
95
|
+
<ul>
|
96
|
+
<% @hashtags.each do |hashtag| %>
|
97
|
+
<li><%= link_to hashtag.name, hashtag_path(hashtag.name) %></li>
|
98
|
+
<% end -%>
|
99
|
+
</ul>
|
100
|
+
```
|
84
101
|
|
85
|
-
|
102
|
+
Show:
|
86
103
|
```erb
|
87
104
|
<h1><%= params[:hashtag] %></h1>
|
88
105
|
<% if @hashtagged %>
|
@@ -100,9 +117,10 @@ In the gem it is actually extracted in a helper.
|
|
100
117
|
|
101
118
|
### Routes
|
102
119
|
|
103
|
-
If you use the provided controller and views, add
|
120
|
+
If you use the provided controller and views, the generator will add two routes to your app:
|
104
121
|
```ruby
|
105
|
-
get 'hashtags
|
122
|
+
get 'hashtags/', to: 'hashtags#index', as: :hashtags
|
123
|
+
get 'hashtags/:hashtag', to: 'hashtags#show', as: :hashtag
|
106
124
|
```
|
107
125
|
|
108
126
|
The helper generating the link relies on it.
|
@@ -1,8 +1,6 @@
|
|
1
|
-
<h1
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<% end -%>
|
6
|
-
<% else -%>
|
7
|
-
<p>There is no match for the <em><%= params[:hashtag] %></em> hashtag.</p>
|
1
|
+
<h1>Hashtags</h1>
|
2
|
+
<ul>
|
3
|
+
<% @hashtags.each do |hashtag| %>
|
4
|
+
<li><%= link_to hashtag.name, hashtag_path(hashtag.name) %></li>
|
8
5
|
<% end -%>
|
6
|
+
</ul>
|
@@ -8,6 +8,10 @@ module SimpleHashtag
|
|
8
8
|
copy_file "views/hashtags_controller.rb", "app/controllers/hashtags_controller.rb"
|
9
9
|
copy_file "views/hashtags_helper.rb", "app/helpers/hashtags_helper.rb"
|
10
10
|
copy_file "views/hashtags_index.html.erb", "app/views/hashtags/index.html.erb"
|
11
|
+
copy_file "views/hashtags_show.html.erb", "app/views/hashtags/show.html.erb"
|
12
|
+
|
13
|
+
route 'get "hashtags", to: "hashtags#index", as: :hashtags'
|
14
|
+
route 'get "hashtags/:hashtag", to: "hashtags#show", as: :hashtag'
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_hashtag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Campardou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,7 +89,6 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- .gitignore
|
91
91
|
- .rspec
|
92
|
-
- .travis.yml
|
93
92
|
- Gemfile
|
94
93
|
- LICENSE.txt
|
95
94
|
- README.md
|
@@ -100,6 +99,7 @@ files:
|
|
100
99
|
- lib/generators/simple_hashtag/templates/views/hashtags_controller.rb
|
101
100
|
- lib/generators/simple_hashtag/templates/views/hashtags_helper.rb
|
102
101
|
- lib/generators/simple_hashtag/templates/views/hashtags_index.html.erb
|
102
|
+
- lib/generators/simple_hashtag/templates/views/hashtags_show.html.erb
|
103
103
|
- lib/generators/simple_hashtag/views_generator.rb
|
104
104
|
- lib/simple_hashtag.rb
|
105
105
|
- lib/simple_hashtag/hashtag.rb
|