blog_helper 0.0.5prerelease → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +42 -0
- data/Rakefile +5 -5
- data/lib/blog_helper.rb +29 -17
- data/lib/serious_blog_helper.rb +3 -4
- metadata +12 -14
- data/README +0 -9
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# BlogHelper
|
2
|
+
|
3
|
+
Having a closer look at ruby based blogging platforms like [serious](http://github.com/colszowka/serious) and [toto](http://cloudhead.io/toto), I missed some functionality.
|
4
|
+
|
5
|
+
This a a collection of tools usable in both platforms.
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- tag your posts
|
10
|
+
- use seo friendly page titles
|
11
|
+
- use the disqus comment counter
|
12
|
+
- a workaround for seriuous allowing you to use generic yaml fields
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
It's a piece of cake: just use the `gem` tool to get going with the _blog_helper_: `sudo gem install blog_helper`
|
17
|
+
|
18
|
+
If you want to use features that rely on accessing the http requests like the _tag_ feature, you'll need to use the [_toto_prerelease_](http://github.com/5v3n/toto).
|
19
|
+
|
20
|
+
Please follow the instrucions there to do so.
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Piece of cake, again: all you have to do is use `<% require 'blog_helper'%>` in your .rhtml or .erb file and call the corresponding methods.
|
25
|
+
|
26
|
+
For example, to use seo friendly titles, your layout.rhtml should be looking like this:
|
27
|
+
|
28
|
+
|
29
|
+
<!doctype html>
|
30
|
+
<html>
|
31
|
+
<head>
|
32
|
+
<% require 'blog_helper'
|
33
|
+
page_title = BlogHelper::generate_title(@path, title, 'yourSitesTitle.com')
|
34
|
+
%>
|
35
|
+
.
|
36
|
+
.
|
37
|
+
.
|
38
|
+
<title><%= page_title %></title>
|
39
|
+
<link rel="alternate" type="application/atom+xml" title="<%= page_title %> - feed" href="/index.xml" />
|
40
|
+
.
|
41
|
+
.
|
42
|
+
.
|
data/Rakefile
CHANGED
@@ -12,16 +12,16 @@ require 'rake/testtask'
|
|
12
12
|
|
13
13
|
spec = Gem::Specification.new do |s|
|
14
14
|
s.name = 'blog_helper'
|
15
|
-
s.version = '0.0.
|
15
|
+
s.version = '0.0.5'
|
16
16
|
s.has_rdoc = true
|
17
|
-
s.extra_rdoc_files = ['README', 'LICENSE']
|
17
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
18
18
|
s.summary = 'Some handy helpers for serious, toto and the likes...'
|
19
19
|
s.description = s.summary
|
20
20
|
s.author = 'Sven Kräuter'
|
21
21
|
s.email = 'sven.krauter@gmx.net'
|
22
|
-
s.homepage = 'http://
|
22
|
+
s.homepage = 'http://github.com/5v3n/blog_helper'
|
23
23
|
# s.executables = ['your_executable_here']
|
24
|
-
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
24
|
+
s.files = %w(LICENSE README.md Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
25
25
|
s.require_path = "lib"
|
26
26
|
s.bindir = "bin"
|
27
27
|
end
|
@@ -33,7 +33,7 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
33
33
|
end
|
34
34
|
|
35
35
|
Rake::RDocTask.new do |rdoc|
|
36
|
-
files =['README', 'LICENSE', 'lib/**/*.rb']
|
36
|
+
files =['README.md', 'LICENSE', 'lib/**/*.rb']
|
37
37
|
rdoc.rdoc_files.add(files)
|
38
38
|
rdoc.main = "README" # page to start on
|
39
39
|
rdoc.title = "BlogHelper Docs"
|
data/lib/blog_helper.rb
CHANGED
@@ -1,31 +1,43 @@
|
|
1
|
-
# Some useful feature for serious, toto and the likes.
|
2
|
-
|
3
|
-
# create a list of links to tagged articles, default link_format: <a href
|
4
|
-
def
|
1
|
+
# Some useful feature for serious, toto and the likes. Basically, any ruby based blog or site.
|
2
|
+
module BlogHelper
|
3
|
+
# create a list of links to tagged articles, default link_format: <code>%&<a href="/tagged?tag=#{tag}" alt="articles concerning #{tag}" >#{tag}</a> &</code>
|
4
|
+
def BlogHelper.tag_link_list(csv_string)
|
5
5
|
# read csv-string into array
|
6
|
-
tag_list =
|
6
|
+
tag_list = csv_to_array(csv_string)
|
7
7
|
if tag_list
|
8
8
|
tag_string = ""
|
9
|
+
#TODO pass a format via parameter
|
9
10
|
tag_list.each { |tag| tag_string << %&<a href="/tagged?tag=#{tag}" alt="articles concerning #{tag}" >#{tag}</a> & }
|
10
11
|
end
|
11
12
|
tag_string
|
12
13
|
end
|
13
14
|
# processes a csv-string into an array
|
14
|
-
def
|
15
|
-
if csv_string
|
15
|
+
def BlogHelper.csv_to_array(csv_string)
|
16
16
|
#split & handle forgotten spaces after the separator. then flatten the multidemnsional array:
|
17
|
-
|
18
|
-
|
17
|
+
csv_string.split(', ').map{ |e| e.split(',')}.flatten if csv_string
|
18
|
+
end
|
19
|
+
# pass the path (@path for a toto blog) & the desired SEO ending, e.g. the name of your blog.
|
20
|
+
# example for toto: <code>seo_friendly_title(@path, title, "mysite.com") will produce 'subpage | mysite.com' as seo friendly page title.</code>
|
21
|
+
def BlogHelper.seo_friendly_title(path, title, seo_ending)
|
22
|
+
#TODO use custom title separator...
|
23
|
+
if path == 'index'
|
24
|
+
page_title = seo_ending
|
25
|
+
elsif path.split('/').compact.length == 4
|
26
|
+
page_title = title << " | #{seo_ending}"
|
27
|
+
else
|
28
|
+
page_title = path.capitalize.gsub(/[-]/, ' ') << " | #{seo_ending}"
|
29
|
+
end
|
30
|
+
page_title
|
19
31
|
end
|
20
|
-
=begin
|
21
|
-
Generates javascript to include to the bottom of your index page.
|
22
|
-
Appending '#disqus_thread' to the end of permalinks will replace the text of these links with the comment count.
|
23
|
-
|
24
|
-
For example, you may have a link with this HTML: <a href="http://example.com/my_article.html#disqus_thread">Comments</a> The comment count code will replace the text "Comments" with the number of comments on the page
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
#Generates javascript to include to the bottom of your index page.
|
34
|
+
#Appending '#disqus_thread' to the end of permalinks will replace the text of these links with the comment count.
|
35
|
+
#
|
36
|
+
#For example, you may have a link with this HTML: <code><a href="http://example.com/my_article.html#disqus_thread">Comments</a> </code> The comment count code will replace the text "Comments" with the number of comments on the page
|
37
|
+
#
|
38
|
+
#(see http://disqus.com/comments/universal/ for details)
|
39
|
+
#
|
40
|
+
def BlogHelper.disqus_comment_count_js(disqus_shortname)
|
29
41
|
%&
|
30
42
|
<script type="text/javascript">
|
31
43
|
var disqus_shortname = '#{disqus_shortname}';
|
data/lib/serious_blog_helper.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
#
|
2
|
-
# and open the template in the editor.
|
1
|
+
# extension to BlogHelper with special methods for serious
|
3
2
|
require 'blog_helper'
|
4
|
-
|
5
|
-
def tags_from_article(article=nil)
|
3
|
+
module SeriousBlogHelper
|
4
|
+
def SeriousBlogHelper.tags_from_article(article=nil)
|
6
5
|
tags_marker = %&tags"=>&
|
7
6
|
if article && article.inspect.index(tags_marker)
|
8
7
|
tags_start_index=article.inspect.index(tags_marker) + tags_marker.length
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blog_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Sven Kr\xC3\xA4uter"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-11 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -26,16 +26,16 @@ executables: []
|
|
26
26
|
extensions: []
|
27
27
|
|
28
28
|
extra_rdoc_files:
|
29
|
-
- README
|
29
|
+
- README.md
|
30
30
|
- LICENSE
|
31
31
|
files:
|
32
32
|
- LICENSE
|
33
|
-
- README
|
33
|
+
- README.md
|
34
34
|
- Rakefile
|
35
35
|
- lib/blog_helper.rb
|
36
36
|
- lib/serious_blog_helper.rb
|
37
37
|
has_rdoc: true
|
38
|
-
homepage: http://
|
38
|
+
homepage: http://github.com/5v3n/blog_helper
|
39
39
|
licenses: []
|
40
40
|
|
41
41
|
post_install_message:
|
@@ -55,14 +55,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
60
|
+
hash: 3
|
61
61
|
segments:
|
62
|
-
-
|
63
|
-
|
64
|
-
- 1
|
65
|
-
version: 1.3.1
|
62
|
+
- 0
|
63
|
+
version: "0"
|
66
64
|
requirements: []
|
67
65
|
|
68
66
|
rubyforge_project:
|
data/README
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
== BlogHelper
|
2
|
-
|
3
|
-
Having a closer look at ruby based blogging platforms like [serious](http://github.com/colszowka/serious) and [toto](http://cloudhead.io/toto), I missed some functionality.
|
4
|
-
|
5
|
-
This a a collection of tools usable in both platforms.
|
6
|
-
|
7
|
-
=== Features
|
8
|
-
|
9
|
-
TBD...
|