Class: Card::Format::HtmlFormat
- Inherits:
-
Card::Format
- Object
- Card::Format
- Card::Format::HtmlFormat
- Defined in:
- mod/core/format/html_format.rb
Direct Known Subclasses
Constant Summary collapse
- LAYOUTS =
builtin layouts allow for rescue / testing
Mod::Loader.load_layouts.merge "none" => "{{_main}}"
Constants included from Render
Constants included from Nest::View
Instance Attribute Summary collapse
-
#options_need_save ⇒ Object
Returns the value of attribute options_need_save.
-
#skip_autosave ⇒ Object
Returns the value of attribute skip_autosave.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Attributes inherited from Card::Format
#card, #error_status, #form, #main_opts, #nest_opts, #parent, #root
Instance Method Summary collapse
- #default_item_view ⇒ Object
-
#focal? ⇒ Boolean
meaning the current card is the requested card.
-
#get_layout_content ⇒ Object
helper methods for layout view.
- #get_nest_defaults(nested_card) ⇒ Object
- #html_escape_except_quotes(s) ⇒ Object
- #layout_from_card_or_code(name) ⇒ Object
- #layout_from_rule ⇒ Object
- #main? ⇒ Boolean
Methods inherited from Card::Format
#controller, #include_set_format_modules, #initialize, #method_missing, #page, #params, #pass_method_to_template_object, #respond_to_missing?, #session, #tagged, #template
Methods included from Nest::ClassMethods
Methods included from Registration
#class_from_name, #extract_class_vars, #extract_view_tags, #format_ancestry, #format_class_name, #format_sym, #new, #register, #tagged
Methods included from Error
#debug_error, #error_cardname, #rendering_error, #rescue_view
Methods included from Content
#add_class, #format_date, #get_content_object, #id_counter, #output, #process_content, #unique_id
Methods included from Names
#add_name_context, #context_names_from_params, #context_names_minus_irrelevants, #initialize_context_names, #showname, #with_name_context
Methods included from Render
#canonicalize_view, #configured_visibility, #current_view, #default_render_args, #hidden_view?, #nest_arg_visibility, #optional_render_args, #parse_view_visibility, #render, #render_api, #show_view?, #view_method
Methods included from Permission
#approved_view, #ok?, #ok_view, #permitted_view, #view_for_unknown
Methods included from Nest
#field_nest, #nest, #nest_card, #nest_defaults, #process_nest
Methods included from Nest::View
Methods included from Nest::Subformat
Methods included from Nest::Main
Methods included from Nest::Fetch
Methods included from Env::Location
#card_path, #card_url, #page_path
Constructor Details
This class inherits a constructor from Card::Format
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Card::Format
Instance Attribute Details
#options_need_save ⇒ Object
Returns the value of attribute options_need_save.
10 11 12 |
# File 'mod/core/format/html_format.rb', line 10 def @options_need_save end |
#skip_autosave ⇒ Object
Returns the value of attribute skip_autosave.
10 11 12 |
# File 'mod/core/format/html_format.rb', line 10 def skip_autosave @skip_autosave end |
#start_time ⇒ Object
Returns the value of attribute start_time.
10 11 12 |
# File 'mod/core/format/html_format.rb', line 10 def start_time @start_time end |
Instance Method Details
#default_item_view ⇒ Object
51 52 53 |
# File 'mod/core/format/html_format.rb', line 51 def default_item_view :closed end |
#focal? ⇒ Boolean
meaning the current card is the requested card
69 70 71 72 73 74 75 |
# File 'mod/core/format/html_format.rb', line 69 def focal? # meaning the current card is the requested card if show_layout? main? else @depth.zero? end end |
#get_layout_content ⇒ Object
helper methods for layout view
16 17 18 19 20 21 22 23 24 |
# File 'mod/core/format/html_format.rb', line 16 def get_layout_content Auth.as_bot do if (requested_layout = params[:layout]) layout_from_card_or_code requested_layout else layout_from_rule end end end |
#get_nest_defaults(nested_card) ⇒ Object
47 48 49 |
# File 'mod/core/format/html_format.rb', line 47 def get_nest_defaults nested_card { view: (nested_card.rule(:default_html_view) || :titled) } end |
#html_escape_except_quotes(s) ⇒ Object
55 56 57 58 59 |
# File 'mod/core/format/html_format.rb', line 55 def html_escape_except_quotes s # to be used inside single quotes (makes for readable json attributes) s.to_s.gsub(/&/, "&").gsub(/\'/, "'") .gsub(/>/, ">").gsub(/</, "<") end |
#layout_from_card_or_code(name) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'mod/core/format/html_format.rb', line 34 def layout_from_card_or_code name layout_card = Card.fetch name.to_s, skip_virtual: true, skip_modules: true if layout_card && layout_card.ok?(:read) layout_card.content elsif (hardcoded_layout = LAYOUTS[name]) hardcoded_layout else "<h1>Unknown layout: #{name}</h1>"\ "Built-in Layouts: #{LAYOUTS.keys.join(', ')}" end end |
#layout_from_rule ⇒ Object
26 27 28 29 30 31 32 |
# File 'mod/core/format/html_format.rb', line 26 def layout_from_rule if (rule = card.rule_card :layout) && (rule.type_id == Card::PointerID) && (layout_name = rule.item_names.first) layout_from_card_or_code layout_name end end |
#main? ⇒ Boolean
61 62 63 64 65 66 67 |
# File 'mod/core/format/html_format.rb', line 61 def main? if show_layout? @depth == 1 && @mainline # assumes layout includes {{_main}} else @depth.zero? && params[:is_main] end end |