code-snippets 0.1.12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/code-snippets.rb +24 -24
  2. metadata +1 -1
data/lib/code-snippets.rb CHANGED
@@ -15,20 +15,20 @@ class CodeSnippets
15
15
  load()
16
16
  end
17
17
 
18
- def page(n='1', logged_in='false')
19
- html_page n, logged_in
18
+ def page(n='1', current_user='guest')
19
+ html_page n, current_user
20
20
  end
21
21
 
22
- def tag(tag, n='1', logged_in='false')
23
- html_tag tag, n, logged_in
22
+ def tag(tag, n='1', current_user='guest')
23
+ html_tag tag, n, current_user
24
24
  end
25
25
 
26
- def user(user, n='1', logged_in='false')
27
- html_user(user, n, logged_in)
26
+ def user(user, n='1', current_user='guest')
27
+ html_user(user, n, current_user)
28
28
  end
29
29
 
30
- def user_tag(user, tag, n='1', logged_in='false')
31
- html_user_tag(user, tag, n, logged_in)
30
+ def user_tag(user, tag, n='1', current_user='guest')
31
+ html_user_tag(user, tag, n, current_user)
32
32
  end
33
33
 
34
34
  def rss()
@@ -47,7 +47,7 @@ class CodeSnippets
47
47
  rss_cached(user+tag) { @blog.user(user).tag(tag).page(1) }
48
48
  end
49
49
 
50
- def show(id, logged_in='false')
50
+ def show(id, current_user='guest')
51
51
 
52
52
  doc = Document.new('<result><summary/><records/></result>')
53
53
  entry = @blog.entry(id).dup
@@ -57,7 +57,7 @@ class CodeSnippets
57
57
  doc.root.elements['summary'].add Element.new('title').add_text(entry.text('title').to_s + tags)
58
58
  prepare_doc doc
59
59
 
60
- render_html(doc, @xsl_doc_single, logged_in).to_s
60
+ render_html(doc, @xsl_doc_single, current_user).to_s
61
61
  end
62
62
 
63
63
  def reload_renderer()
@@ -79,38 +79,38 @@ class CodeSnippets
79
79
 
80
80
  private
81
81
 
82
- def html_page(n, logged_in='false')
82
+ def html_page(n, current_user='guest')
83
83
  @args = [n]
84
84
  summary = {title: 'Snippets'}
85
- html_cached(context=@args, summary, logged_in) { @blog.page(n.to_i) }
85
+ html_cached(context=@args, summary, current_user) { @blog.page(n.to_i) }
86
86
  end
87
87
 
88
- def html_tag(tag, pg_n, logged_in='false')
88
+ def html_tag(tag, pg_n, current_user='guest')
89
89
  @args = [tag, pg_n]
90
90
  summary = {title: tag + ' code', tag: tag}
91
- html_cached(context=@args, summary, logged_in) { @blog.tag(tag).page(pg_n.to_i) }
91
+ html_cached(context=@args, summary, current_user) { @blog.tag(tag).page(pg_n.to_i) }
92
92
  end
93
93
 
94
- def html_user(user, pg_n, logged_in='false')
94
+ def html_user(user, pg_n, current_user='guest')
95
95
  @args = ['user', user, pg_n]
96
96
  summary = {title: 'Snippets', user: user}
97
- html_cached(context=@args, summary, logged_in) { @blog.user(user).page(pg_n.to_i) }
97
+ html_cached(context=@args, summary, current_user) { @blog.user(user).page(pg_n.to_i) }
98
98
  end
99
99
 
100
- def html_user_tag(user, tag, pg_n, logged_in='false')
100
+ def html_user_tag(user, tag, pg_n, current_user='guest')
101
101
  @args = ['user', user, 'tag', tag, pg_n]
102
102
  summary = {title: 'Snippets', user: user, tag: tag}
103
- html_cached(context=@args, summary, logged_in) { @blog.user(user).tag(tag).page(pg_n.to_i) }
103
+ html_cached(context=@args, summary, current_user) { @blog.user(user).tag(tag).page(pg_n.to_i) }
104
104
  end
105
105
 
106
- def html_cached(context, summary, logged_in='false', &b)
106
+ def html_cached(context, summary, current_user='guest', &b)
107
107
  c = context.join
108
108
  @page_cache.read(c) do
109
- view_html(@doc_cache.read(c){b.call}, c, summary, logged_in).to_s
109
+ view_html(@doc_cache.read(c){b.call}, c, summary, current_user).to_s
110
110
  end
111
111
  end
112
112
 
113
- def view_html(raw_doc, context, summary, logged_in='false')
113
+ def view_html(raw_doc, context, summary, current_user='guest')
114
114
 
115
115
  blk = lambda do
116
116
  page_doc = Document.new(raw_doc.to_s)
@@ -148,7 +148,7 @@ class CodeSnippets
148
148
 
149
149
  xml_doc = context != '1' ? @hc_xml.read(context, &blk) : blk.call
150
150
 
151
- render_html(xml_doc, @xsl_doc, logged_in)
151
+ render_html(xml_doc, @xsl_doc, current_user)
152
152
 
153
153
  end
154
154
 
@@ -245,8 +245,8 @@ class CodeSnippets
245
245
 
246
246
  end
247
247
 
248
- def render_html(xml_doc, xsl_doc, logged_in)
249
- xsl_params = ['logged_in', logged_in]
248
+ def render_html(xml_doc, xsl_doc, current_user)
249
+ xsl_params = ['current_user', current_user]
250
250
  Nokogiri::XSLT(xsl_doc.to_s).transform(Nokogiri::XML(xml_doc.to_s), Nokogiri::XSLT.quote_params(xsl_params))
251
251
  end
252
252
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors: []
7
7