fnando-glue 0.0.4 → 0.0.5
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/README.markdown +7 -0
- data/Rakefile +6 -0
- data/glue.gemspec +1 -1
- data/lib/glue.rb +1 -1
- data/lib/glue/template/feed.rb +11 -9
- data/lib/glue/template/helper.rb +20 -6
- data/templates/main.haml +1 -0
- metadata +1 -1
data/README.markdown
CHANGED
@@ -23,6 +23,13 @@ Just run `glue /some/path` to generate your site skeleton.
|
|
23
23
|
|
24
24
|
[TODO: Write more about it]
|
25
25
|
|
26
|
+
RUNNING TESTS
|
27
|
+
-------------
|
28
|
+
|
29
|
+
Install the <http://github.com/fnando/rspec-hpricot-matchers> gem.
|
30
|
+
|
31
|
+
Then run `rake spec` or just `rake`.
|
32
|
+
|
26
33
|
TODO
|
27
34
|
----
|
28
35
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rake"
|
2
2
|
require File.dirname(__FILE__) + "/lib/glue"
|
3
|
+
require "spec/rake/spectask"
|
3
4
|
|
4
5
|
PKG_FILES = %w(Rakefile glue.gemspec README.markdown) + Dir["{bin,lib,templates}/**/*"]
|
5
6
|
|
@@ -74,3 +75,8 @@ namespace :gem do
|
|
74
75
|
system "rm *.gem"
|
75
76
|
end
|
76
77
|
end
|
78
|
+
|
79
|
+
task :default => :spec
|
80
|
+
Spec::Rake::SpecTask.new do |t|
|
81
|
+
t.spec_opts = ["-c", "-f s"]
|
82
|
+
end
|
data/glue.gemspec
CHANGED
data/lib/glue.rb
CHANGED
data/lib/glue/template/feed.rb
CHANGED
@@ -17,12 +17,12 @@ module Glue
|
|
17
17
|
|
18
18
|
# instantiate builder
|
19
19
|
xml = Builder::XmlMarkup.new(:target => file, :indent => 2)
|
20
|
-
xml.instruct! :xml, :version => "1.
|
20
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
21
21
|
|
22
22
|
feed_opts = {
|
23
23
|
"xmlns" => "http://www.w3.org/2005/Atom",
|
24
24
|
"xml:lang" => config[:site][:language],
|
25
|
-
"xml:base" =>
|
25
|
+
"xml:base" => config[:site][:base_url]
|
26
26
|
}
|
27
27
|
|
28
28
|
xml.feed(feed_opts) do
|
@@ -30,10 +30,15 @@ module Glue
|
|
30
30
|
xml.id config[:site][:base_url]
|
31
31
|
|
32
32
|
# set title
|
33
|
-
xml.title config[:site][:title]
|
33
|
+
xml.title { xml.cdata! config[:site][:title] }
|
34
34
|
|
35
35
|
# set description
|
36
|
-
xml.subtitle config[:site][:description]
|
36
|
+
xml.subtitle { xml.cdata! config[:site][:description] }
|
37
|
+
|
38
|
+
# set author
|
39
|
+
xml.author do
|
40
|
+
xml.name { xml.cdata! config[:site][:title] }
|
41
|
+
end
|
37
42
|
|
38
43
|
# set link to site
|
39
44
|
xml.link(:href => config[:site][:base_url])
|
@@ -47,15 +52,12 @@ module Glue
|
|
47
52
|
# add generator info
|
48
53
|
xml.generator("Glue", :uri => "http://github.com/fnando/glue", :version => Glue::VERSION)
|
49
54
|
|
50
|
-
# set language
|
51
|
-
xml.language config[:site][:language]
|
52
|
-
|
53
55
|
filtered_items.each do |options|
|
54
56
|
url = File.join(config[:site][:base_url], options[:path])
|
55
57
|
|
56
58
|
xml.entry do
|
57
|
-
xml.title options[:title]
|
58
|
-
xml.summary options[:description]
|
59
|
+
xml.title { xml.cdata! options[:title] }
|
60
|
+
xml.summary { xml.cdata! options[:description] }
|
59
61
|
xml.updated options[:updated_at].xmlschema
|
60
62
|
xml.link :rel => "alternate", :type => "text/html", :href => url
|
61
63
|
xml.id url
|
data/lib/glue/template/helper.rb
CHANGED
@@ -2,16 +2,30 @@ module Glue
|
|
2
2
|
module Template
|
3
3
|
class Helper
|
4
4
|
def config
|
5
|
-
@config ||=
|
5
|
+
@config ||= Glue::Config.new
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def feed_tag
|
9
|
+
haml '%link{"href" => url_for("feed.xml", :full => true), "rel" => "alternate", "title" => config[:site][:title], "type" => "application/atom+xml"}'
|
10
|
+
end
|
11
|
+
|
12
|
+
def url_for(path, options={})
|
13
|
+
uri = URI.parse(config[:site][:base_url])
|
14
|
+
|
15
|
+
host = uri.scheme + "://" + uri.host
|
16
|
+
host << ":#{uri.port}" unless (uri.scheme == "http" && uri.port == 80) || (uri.scheme == "https" && uri.port == 443)
|
17
|
+
|
10
18
|
base_path = uri.path.chomp("/")
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
parts = []
|
21
|
+
parts << host if options[:full]
|
22
|
+
parts << base_path
|
23
|
+
parts << path
|
24
|
+
|
25
|
+
url = File.join(*parts)
|
26
|
+
|
27
|
+
url << ".html" if config[:site][:friendly_url] == false && url !~ /\.[a-z0-9]+$/
|
28
|
+
url
|
15
29
|
end
|
16
30
|
|
17
31
|
def markdown(text)
|
data/templates/main.haml
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
%meta{"http-equiv" => "last-update", "content" => last_update}
|
11
11
|
%link{"rel" => "shortcut icon", "href" => "/favicon.ico", "type" => "image/x-icon"}
|
12
12
|
%link{"rel" => "stylesheet", "href" => "/stylesheets/style.css", "type" => "text/css"}
|
13
|
+
= feed_tag
|
13
14
|
|
14
15
|
%body{"id" => id}
|
15
16
|
#page
|