blog_helper 0.0.5prerelease
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +22 -0
- data/README +9 -0
- data/Rakefile +46 -0
- data/lib/blog_helper.rb +41 -0
- data/lib/serious_blog_helper.rb +13 -0
- metadata +74 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
== BlogHelper
|
2
|
+
|
3
|
+
Copyright (c) 2010 Sven Kräuter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README
ADDED
@@ -0,0 +1,9 @@
|
|
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...
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
require 'rake/testtask'
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = 'blog_helper'
|
15
|
+
s.version = '0.0.5prerelease'
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
18
|
+
s.summary = 'Some handy helpers for serious, toto and the likes...'
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = 'Sven Kräuter'
|
21
|
+
s.email = 'sven.krauter@gmx.net'
|
22
|
+
s.homepage = 'http://5v3n.com'
|
23
|
+
# s.executables = ['your_executable_here']
|
24
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
25
|
+
s.require_path = "lib"
|
26
|
+
s.bindir = "bin"
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |p|
|
30
|
+
p.gem_spec = spec
|
31
|
+
p.need_tar = true
|
32
|
+
p.need_zip = true
|
33
|
+
end
|
34
|
+
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
37
|
+
rdoc.rdoc_files.add(files)
|
38
|
+
rdoc.main = "README" # page to start on
|
39
|
+
rdoc.title = "BlogHelper Docs"
|
40
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
41
|
+
rdoc.options << '--line-numbers'
|
42
|
+
end
|
43
|
+
|
44
|
+
Rake::TestTask.new do |t|
|
45
|
+
t.test_files = FileList['test/**/*.rb']
|
46
|
+
end
|
data/lib/blog_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Some useful feature for serious, toto and the likes.
|
2
|
+
class BlogHelper
|
3
|
+
# create a list of links to tagged articles, default link_format: <a href=/tagged?tag=&+tag+%& >#{tag}</a>
|
4
|
+
def create_tag_link_list(csv_string)
|
5
|
+
# read csv-string into array
|
6
|
+
tag_list = process_to_array(csv_string)
|
7
|
+
if tag_list
|
8
|
+
tag_string = ""
|
9
|
+
tag_list.each { |tag| tag_string << %&<a href="/tagged?tag=#{tag}" alt="articles concerning #{tag}" >#{tag}</a> & }
|
10
|
+
end
|
11
|
+
tag_string
|
12
|
+
end
|
13
|
+
# processes a csv-string into an array
|
14
|
+
def process_to_array(csv_string)
|
15
|
+
if csv_string
|
16
|
+
#split & handle forgotten spaces after the separator. then flatten the multidemnsional array:
|
17
|
+
result = csv_string.split(', ').map{ |e| e.split(',')}.flatten
|
18
|
+
end
|
19
|
+
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
|
+
|
26
|
+
(see http://disqus.com/comments/universal/ for details)
|
27
|
+
=end
|
28
|
+
def disqus_comment_count_js(disqus_shortname)
|
29
|
+
%&
|
30
|
+
<script type="text/javascript">
|
31
|
+
var disqus_shortname = '#{disqus_shortname}';
|
32
|
+
(function () {
|
33
|
+
var s = document.createElement('script'); s.async = true;
|
34
|
+
s.src = 'http://disqus.com/forums/#{disqus_shortname}/count.js';
|
35
|
+
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
36
|
+
}());
|
37
|
+
</script>
|
38
|
+
|
39
|
+
& if disqus_shortname
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
require 'blog_helper'
|
4
|
+
class SeriousBlogHelper < BlogHelper
|
5
|
+
def tags_from_article(article=nil)
|
6
|
+
tags_marker = %&tags"=>&
|
7
|
+
if article && article.inspect.index(tags_marker)
|
8
|
+
tags_start_index=article.inspect.index(tags_marker) + tags_marker.length
|
9
|
+
tags_end_index = article.inspect.index("\"," ,tags_start_index)
|
10
|
+
tags = article.inspect[tags_start_index+1..tags_end_index-1]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blog_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: -2135978552
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5prerelease
|
10
|
+
version: 0.0.5prerelease
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Sven Kr\xC3\xA4uter"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-08 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Some handy helpers for serious, toto and the likes...
|
23
|
+
email: sven.krauter@gmx.net
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README
|
30
|
+
- LICENSE
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- lib/blog_helper.rb
|
36
|
+
- lib/serious_blog_helper.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://5v3n.com
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 25
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 3
|
64
|
+
- 1
|
65
|
+
version: 1.3.1
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Some handy helpers for serious, toto and the likes...
|
73
|
+
test_files: []
|
74
|
+
|