Module: Story::Utils
- Included in:
- Base
- Defined in:
- lib/story/utils.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_last_session_url ⇒ Object
- #load_additional_styles ⇒ Object
- #parse_file(filename, extension = '', root = true) ⇒ Object
- #set_session_url ⇒ Object
- #title(*sections) ⇒ Object
- #title_type(type_given = false) ⇒ Object
Class Method Details
Instance Method Details
#get_last_session_url ⇒ Object
26 27 28 |
# File 'lib/story/utils.rb', line 26 def get_last_session_url @last_session = request.["session_url"] != "" ? request.["session_url"] : '/' end |
#load_additional_styles ⇒ Object
3 4 5 6 7 8 |
# File 'lib/story/utils.rb', line 3 def load_additional_styles begin settings.additional_stylesheets rescue NoMethodError end end |
#parse_file(filename, extension = '', root = true) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/story/utils.rb', line 34 def parse_file filename, extension = '', root = true file_path = "#{'.' if root}#{filename}.#{extension}" raise not_found if not File.exists? file_path content_type case extension when "xml" then "text/#{extension}" when "mp3", "mp4", "ogg", "mpeg" then "audio/#{extension}" when "json", "pdf", "zip" then "application/#{extension}" when "png", "gif", "jpg", "jpeg", "svg", "tiff" then "image/#{extension}" else "text/plain" end File.read file_path end |
#set_session_url ⇒ Object
30 31 32 |
# File 'lib/story/utils.rb', line 30 def set_session_url response. "session_url", request.path_info if !(request.path_info.match /^e_/).is_a? NilClass and @last_session != request.path_info end |
#title(*sections) ⇒ Object
16 17 18 19 20 |
# File 'lib/story/utils.rb', line 16 def title *sections sections.each do |section| @title += "#{settings.title_separator}#{section.to_s}" end end |
#title_type(type_given = false) ⇒ Object
22 23 24 |
# File 'lib/story/utils.rb', line 22 def title_type type_given = false @title = "(#{type_given}) #{@title}" if type_given end |