Module: ContentHelpers
- Defined in:
- lib/coursegen/course/helpers/content_helpers.rb
Instance Method Summary collapse
- #bold_red(string) ⇒ Object
- #carousel(filenames) ⇒ Object
- #code_begin ⇒ Object
- #code_end ⇒ Object
- #code_string(str) ⇒ Object
- #deliverable(string) ⇒ Object
- #discussion(string) ⇒ Object
- #generate_detailed_schedule(section) ⇒ 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
24 25 26 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 24 def bold_red string "<span style=\"color: red; font-style: italic;\">\#{string}</span>" end |
#carousel(filenames) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 79 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
119 120 121 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 119 def code_begin "\n~~~~~~" end |
#code_end ⇒ Object
123 124 125 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 123 def code_end "~~~~~~\n" end |
#code_string(str) ⇒ Object
127 128 129 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 127 def code_string (str) code_begin + "\n" + str + code_end end |
#deliverable(string) ⇒ Object
63 64 65 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 63 def deliverable string "*Deliverable:*{: style=\"color: red\"} *#{string}*" end |
#discussion(string) ⇒ Object
71 72 73 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 71 def discussion string "*Discussion:*{: style=\"color: blue\"} *#{string}*" end |
#generate_detailed_schedule(section) ⇒ Object
2 3 4 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 2 def generate_detailed_schedule section # binding.pry end |
#homework_hdr ⇒ Object
75 76 77 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 75 def homework_hdr "#### Homework due for today" end |
#important(string = ":") ⇒ Object
51 52 53 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 51 def important string=":" "**Important#{string}**{: style=\"color: red\"}" end |
#include_code(name) ⇒ Object
131 132 133 134 135 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 131 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
41 42 43 44 45 46 47 48 49 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 41 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=\"/content/images/\#{filename_string}\" class=\"img-responsive img-thumbnail\" />\n</div>\n</div>\n" end |
#include_image_old(string, extra_class: nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 34 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
113 114 115 116 117 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 113 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
6 7 8 9 10 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 6 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
32 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 32 def ir string; italic_red(string); end |
#italic_red(string) ⇒ Object
28 29 30 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 28 def italic_red string " *#{string}*{: style=\"color: red\"} " end |
#link_to_doc(label, file_name) ⇒ Object
16 17 18 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 16 def link_to_doc label, file_name "<a href=\"/docs/#{file_name}\">#{label}</a>" end |
#lookup_nitem(the_sect, short_name) ⇒ Object
12 13 14 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 12 def lookup_nitem the_sect, short_name Toc.instance.lookup_citem(the_sect, short_name).nitem end |
#nb(string = "") ⇒ Object
55 56 57 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 55 def nb string="" "*NB: #{string}*{: style=\"color: green\"}" end |
#ruby_begin ⇒ Object
101 102 103 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 101 def ruby_begin "\n~~~~~~" end |
#ruby_end ⇒ Object
105 106 107 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 105 def ruby_end "~~~~~~\n {: .language-ruby}" end |
#ruby_string(str) ⇒ Object
109 110 111 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 109 def ruby_string (str) ruby_begin + "\n" + str + "\n" + ruby_end end |
#tbd(string = "") ⇒ Object
59 60 61 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 59 def tbd string="" "*[TO BE DETERMINED#{string}]*{: style=\"color: red\"}" end |
#team_deliverable(string) ⇒ Object
67 68 69 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 67 def team_deliverable string "*Team Deliverable:*{: style=\"color: red\"} *#{string}*" end |
#toc_link_to(item) ⇒ Object
20 21 22 |
# File 'lib/coursegen/course/helpers/content_helpers.rb', line 20 def toc_link_to item link_to_unless_current item[:title], item end |