publinator 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,30 +7,103 @@ module Publinator
7
7
  end
8
8
 
9
9
  def m(markdown_text)
10
+ return if !markdown_text || markdown_text.blank?
10
11
  RDiscount.new(markdown_text).to_html.html_safe
11
12
  end
12
13
 
13
14
  def menu_section(title, path = "", collection)
15
+ logger.info "Generating Menu Section for #{title}"
14
16
  if path.blank?
15
- ct = "<li>#{title}<br>"
17
+ ct = "
18
+ <li id=\"#{title.underscore}\">#{title}<br>\n"
16
19
  else
17
- ct = "<li><a href='#{path}'>#{title}</a><br>"
20
+ ct = "
21
+ <li id=\"#{title.underscore}\"><a href='#{path}'>#{title}</a><br>\n"
18
22
  end
19
23
  if collection && collection.length && collection.length > 0
20
- ct += "<div class='submenu'><ul>"
24
+ ct += "<div class='submenu'>
25
+ <ul>"
21
26
  collection.each do |c|
22
27
  ct += menu_section(c.title, c.path, c.menu_collection)
23
28
  end
24
- ct += "</ul></div>"
29
+ ct += "</ul>
30
+ </div>"
31
+ else
32
+ logger.info "collection: #{ collection } did not generate a submenu."
25
33
  end
26
34
  ct += "</li>"
27
35
  ct.html_safe
28
36
  end
29
37
 
30
- def menu_item(obj)
31
- menu_section(obj.title, obj.path, obj.menu_collection)
38
+
39
+ def menu_item(object)
40
+ if object.respond_to?(:is_publishable?)
41
+ li_tag(object)
42
+ else
43
+ collection_li_tag(object)
44
+ end
32
45
  end
33
46
 
47
+ def collection_li_tag(object)
48
+ collection_title = object.first.collection_name
49
+ collection_slug = object.first.class.to_s.tableize.humanize
50
+ collection_path = "/#{object.first.class.to_s.tableize}"
51
+
52
+ # object is an array
53
+ # 1. add a link to the collection name
54
+ # 2. add a ul for the collection
55
+ # 3. add li tags for each object in the collection
56
+
57
+
58
+ content_tag(:li, :id => object.first.class.to_s.tableize) do
59
+ li_content = ""
60
+ li_content += link_to collection_title, collection_path
61
+
62
+
63
+ li_content += content_tag(:div, :class => 'submenu', :id => object.first.class.to_s.tableize) do
64
+ div_contents = ""
65
+ div_contents += content_tag(:ul) do
66
+ next_contents = ""
67
+ object.each do |o|
68
+ next_contents += li_tag(o)
69
+ end
70
+ next_contents.html_safe
71
+ end
72
+ div_contents.html_safe
73
+ end
74
+
75
+ li_content.html_safe
76
+ end
77
+ end
78
+
79
+ def li_tag(object)
80
+ content_tag(:li, :id => object.my_slug) do
81
+ li_content = ""
82
+ li_content += link_to object.title, object.path
83
+ if object.menu_collection && object.menu_collection.length > 0
84
+ li_content += ("<br>" + submenu(object).html_safe)
85
+ end
86
+ li_content.html_safe
87
+ end
88
+ end
89
+
90
+ def submenu(object)
91
+ obj_slug = object.respond_to?(:slug) ? object.slug : object.my_slug
92
+ content_tag(:div, :class => 'submenu', :id => obj_slug) do
93
+ div_content = ""
94
+ ul_content = ""
95
+ div_content += content_tag(:ul) do
96
+ object.menu_collection.each{ |mco| ul_content += li_tag(mco) }
97
+ ul_content.html_safe
98
+ end
99
+ div_content.html_safe
100
+ end
101
+ end
102
+
103
+ #def menu_item(obj)
104
+ #menu_section(obj.title, obj.path, obj.menu_collection)
105
+ #end
106
+
34
107
  def publishable_asset(pub, asset_type)
35
108
  return if !pub
36
109
  asset = pub.asset_file(asset_type)
@@ -6,6 +6,7 @@ module Publinator
6
6
  has_many :publications, :class_name => "Publinator::Publication"
7
7
  before_create :generate_section_slug
8
8
  alias_attribute :title, :name
9
+ alias_attribute :slug, :section_slug
9
10
 
10
11
  def self.matches?(request)
11
12
  pt = self.find(:first, :conditions => ["section_slug = ?", request.path_parameters[:section]])
data/lib/publinator.rb CHANGED
@@ -38,6 +38,10 @@ module Publinator
38
38
  end
39
39
  end
40
40
 
41
+ def is_publishable?
42
+ true
43
+ end
44
+
41
45
  def asset_types
42
46
  []
43
47
  end
@@ -48,6 +52,11 @@ module Publinator
48
52
  end
49
53
 
50
54
  def my_slug
55
+ if self.respond_to?(:slug)
56
+ unless self.slug.blank?
57
+ return slug
58
+ end
59
+ end
51
60
  publication.slug
52
61
  end
53
62
 
@@ -1,3 +1,3 @@
1
1
  module Publinator
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-22 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -350,7 +350,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
350
350
  version: '0'
351
351
  segments:
352
352
  - 0
353
- hash: -77903522241391316
353
+ hash: 1803182662308414009
354
354
  required_rubygems_version: !ruby/object:Gem::Requirement
355
355
  none: false
356
356
  requirements:
@@ -359,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  segments:
361
361
  - 0
362
- hash: -77903522241391316
362
+ hash: 1803182662308414009
363
363
  requirements: []
364
364
  rubyforge_project:
365
365
  rubygems_version: 1.8.24