Module: ContentHelpers
- Defined in:
- lib/coursegen/course/helpers/content_helpers.rb
Instance Method Summary collapse
- #bold_red(string) ⇒ Object
- #callout(title, body, format = nil) ⇒ Object
- #carousel(filenames) ⇒ Object
- #code_begin ⇒ Object
- #code_end ⇒ Object
- #code_string(str) ⇒ Object
- #deliverable(string) ⇒ Object
- #discussion(string) ⇒ Object
- #homework_hdr ⇒ Object
- #important(string = ":") ⇒ Object
- #include_code(name) ⇒ Object
- #include_image(filename_string, width: 8) ⇒ Object
- #include_image_old(string, extra_class: nil) ⇒ Object
- #include_ruby(name) ⇒ Object
- #include_topic(item_symbol) ⇒ Object
- #ir(string) ⇒ Object
- #italic_red(string) ⇒ Object
- #link_to_doc(label, file_name) ⇒ Object
- #lookup_nitem(the_sect, short_name) ⇒ Object
- #nb(string = "") ⇒ Object
- #ruby_begin ⇒ Object
- #ruby_end ⇒ Object
- #ruby_string(str) ⇒ Object
- #tbd(string = "") ⇒ Object
- #team_deliverable(string) ⇒ Object
- #toc_link_to(item) ⇒ Object
Instance Method Details
#bold_red(string) ⇒ Object
21 22 23 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 21 def bold_red string "<span style=\"color: red; font-style: italic;\">#{string}</span>" end |
#callout(title, body, format = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 31 def callout title, body, format=nil template_string = "<div class=\"well well-sm\">\n<span class=\"label label-primary\">\#{title}</span>\#{body}\n</div>\n" end |
#carousel(filenames) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 84 def carousel(filenames) body = %~<div id="myCarousel" class="carousel slide" style="width: 500px; margin: 0 auto;"> <div class="carousel-inner" style="margin: 20px; ">~ counter = 0 filenames.each do |nam| if counter == 0 body << %~<div class="item active">~ else body << %~<div class="item">~ end body << %~<img src="~ body << "/content/images/#{nam}" body << %~" class="img-polaroid" alt=""></div>~ counter += 1 end body << %~</div> <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a> </div>~ body end |
#code_begin ⇒ Object
124 125 126 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 124 def code_begin "\n~~~~~~" end |
#code_end ⇒ Object
128 129 130 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 128 def code_end "~~~~~~\n" end |
#code_string(str) ⇒ Object
132 133 134 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 132 def code_string (str) code_begin + "\n" + str + code_end end |
#deliverable(string) ⇒ Object
68 69 70 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 68 def deliverable string "*Deliverable:*{: style=\"color: red\"} *#{string}*" end |
#discussion(string) ⇒ Object
76 77 78 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 76 def discussion string "*Discussion:*{: style=\"color: blue\"} *#{string}*" end |
#homework_hdr ⇒ Object
80 81 82 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 80 def homework_hdr "#### Homework due for today" end |
#important(string = ":") ⇒ Object
56 57 58 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 56 def important string=":" "**Important#{string}**{: style=\"color: red\"}" end |
#include_code(name) ⇒ Object
136 137 138 139 140 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 136 def include_code name filename = Dir.pwd+"/content/content/topics/scripts/"+name filecontents = File.new(filename).read code_string filecontents end |
#include_image(filename_string, width: 8) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 46 def include_image filename_string, width: 8 template_string = "<div class=\"row\">\n<div class=\"col-md-offset-2 col-md-\#{width}\">\n <img src=\"../\#{filename_string}\" class=\"img-responsive img-thumbnail\" />\n</div>\n</div>\n" end |
#include_image_old(string, extra_class: nil) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 39 def include_image_old string, extra_class: nil css_class = "img-responsive" css_class += " img-"+extra_class unless extra_class.nil? "<img src=\"/content/images/#{string}\" class=\"%s\" />" % css_class end |
#include_ruby(name) ⇒ Object
118 119 120 121 122 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 118 def include_ruby name filename = Dir.pwd+"/content/content/topics/scripts/"+name.to_s+".rb" filecontents = File.new(filename).read ruby_string filecontents end |
#include_topic(item_symbol) ⇒ Object
3 4 5 6 7 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 3 def include_topic item_symbol incorporated_topic = lookup_nitem("topics", item_symbol.to_s) Toc.instance.record_inclusion @item, incorporated_topic items[incorporated_topic.identifier].compiled_content end |
#ir(string) ⇒ Object
29 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 29 def ir string; italic_red(string); end |
#italic_red(string) ⇒ Object
25 26 27 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 25 def italic_red string " *#{string}*{: style=\"color: red\"} " end |
#link_to_doc(label, file_name) ⇒ Object
13 14 15 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 13 def link_to_doc label, file_name "<a href=\"/docs/#{file_name}\">#{label}</a>" end |
#lookup_nitem(the_sect, short_name) ⇒ Object
9 10 11 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 9 def lookup_nitem the_sect, short_name Toc.instance.lookup_citem(the_sect, short_name).nitem end |
#nb(string = "") ⇒ Object
60 61 62 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 60 def nb string="" "*NB: #{string}*{: style=\"color: green\"}" end |
#ruby_begin ⇒ Object
106 107 108 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 106 def ruby_begin "\n~~~~~~" end |
#ruby_end ⇒ Object
110 111 112 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 110 def ruby_end "~~~~~~\n {: .language-ruby}" end |
#ruby_string(str) ⇒ Object
114 115 116 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 114 def ruby_string (str) ruby_begin + "\n" + str + "\n" + ruby_end end |
#tbd(string = "") ⇒ Object
64 65 66 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 64 def tbd string="" "*[TO BE DETERMINED#{string}]*{: style=\"color: red\"}" end |
#team_deliverable(string) ⇒ Object
72 73 74 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 72 def team_deliverable string "*Team Deliverable:*{: style=\"color: red\"} *#{string}*" end |
#toc_link_to(item) ⇒ Object
17 18 19 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 17 def toc_link_to item link_to_unless_current item[:title], item end |