Class: Template

Inherits:
TextDocument show all
Defined in:
app/models/template.rb

Overview

Definitions:

  • master template: used to render a node. It is used depending on it’s ‘target_klass’ filter.

  • helper template: included into another template.

Render —> Master template –include–> helper template –include–> …

For master templates, the title is build from the different filters (target_klass, mode, format):

Klass-mode-format. Examples: Node-index, Node–xml, Project-info. Note how the format is omitted when it is ‘html’.

Other templates have a title built from the given name, just like any other node.

Constant Summary collapse

MODE_FORMAT_FROM_TITLE =
/^([A-Z][a-zA-Z]+?)(-(([a-zA-Z_\+]*)(-([a-zA-Z_]+)|))|)(\.|\Z)/

Constants inherited from Node

Node::Caster, Node::VERSION_ATTRIBUTES

Constants included from Zena::Use::Workflow

Zena::Use::Workflow::WORKFLOW_ATTRIBUTES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TextDocument

accept_content_type_change?, #can_parse_assets?, #export_keys, #file, #file=, #filepath, #parse_assets, #parse_keys, #size, #sweep_cache, #unparse_assets

Methods inherited from Document

accept_content_type_change?, change_to_classes_for_form, document_class_from_content_type, #file=, #filepath, #image?, new, o_new, #size, version_class

Methods inherited from Node

#all_relations, allowed_change_to_classes, #archive, #asset_path, #author, author_proc, auto_create_discussion, #can_auto_create_discussion?, #can_comment?, cast_to_class, change_to_classes_for_form, class_for_relation, classes_for_form, #comments, #comments_count, #content_lang, create_node, create_nodes_from_folder, create_or_update_node, #data, #discussion, #dyn_attribute_keys, #empty?, #export_keys, #export_to_folder, extract_archive, find_by_parent_title_and_kpath, find_by_title, find_by_zip, #find_node_by_pseudo, find_node_by_pseudo, get_attributes_from_yaml, get_class, #get_discussion_id, #get_project_id, get_role, #get_section_id, inherited, inspect, #klass, #klass=, #klass_changed?, kpath_match?, #kpath_match?, kpaths_for_form, load_unhandled_children, #login_info, #m_author, #m_author=, #m_text, #m_text=, #m_title, #m_title=, make_schema, #merge_multi_errors, native_classes, native_classes_by_name, new, #new_child, new_node, #o_skin, #o_user, #parent, #parent_zip, #parent_zip=, #parse_assets, #parse_keys, plural_relation?, #project, #project_zip, #rcast, #real_project, #real_section, #reload, #replace_attributes_in_values, #safe_method_type, #safe_send, #section, #section_zip, #skin_zip, #skin_zip=, #sweep_cache, #to_yaml, transform_attributes, translate_pseudo_id, #unparse_assets, #update_attributes_with_transformation, #user, #user_zip, #v_number, #vclass, #versions_with_secure, #virtual_class, #virtual_class=, #vkind_of?, zafu_attribute, #zafu_eval, #zafu_versions

Methods included from Zena::Use::Search::NodeClassMethods

#match_query, #search_index, #search_records, #search_text

Methods included from Zena::Acts::Secure

#secure_scope, #secure_write_scope, #visitor=

Methods included from Zena::Acts::Secure::SecureResult

#construct_id_map, #secure_result

Methods included from Zena::Acts::SecureNode

#acts_as_secure_node

Methods included from Zena::Use::Dates::ModelMethods

included

Methods included from Zena::Use::Dates::Common

#format_date

Methods included from Zena::Use::QueryNode::ModelMethods

#db_attr, #find, included, #safe_first, #start_node_zip

Methods included from Zena::Use::ScopeIndex::ModelMethods

included, #rebuild_index_with_scope_index!, #rebuild_scope_index!, #scope_index, scope_index_proc

Methods included from Zena::Use::Relations::ModelMethods

#add_link, #all_relations, included, #l_comment, #l_comment=, #l_date, #l_date=, #l_status, #l_status=, #link_id, #link_id=, #linked_node, #linked_node=, #rel, #rel=, #rel_attributes=, #relation_alias, #relation_links, #relation_proxy, #relation_proxy_from_link, #relations_for_form, #remove_link

Methods included from Zena::Use::Fulltext::ModelMethods

included, #rebuild_index_for_version_with_fulltext

Methods included from Zena::Use::PropEval::ModelMethods

included, #merge_prop_eval, #need_set__id, #rebuild_index_for_version_with_prop_eval, #set__id

Methods included from Zena::Use::VersionHash::ModelMethods

#rebuild_vhash, #v_public?, #version, #version_id, #vhash, #visible_versions

Methods included from Zena::Acts::Serializable::ModelMethods

#all_link_ids, #default_serialization_options, #export_ids, #export_properties, included, #to_xml

Methods included from Zena::Use::Ancestry::ModelMethods

#ancestors, #basepath, #fullpath_as_title, included, #is_ancestor?, #pseudo_id, #short_path, #z_ancestors

Methods included from Zena::Use::Workflow

#after_all, #apply, #apply_with_callbacks, #auto_publish?, #can_apply?, #can_destroy_version?, #can_edit?, #can_propose?, #can_publish?, #can_refuse?, #can_remove?, #can_unpublish?, #can_update?, #destroy_version, #edit_content!, #get_publish_from, included, #propose, #publish, #redit, #refuse, #remove, #set_current_transition, #traductions, #transition_allowed?, #transition_for, #unpublish, #update_attributes, #would_change_original?

Methods included from Zena::Use::NestedAttributesAlias::ModelMethods

#attributes_with_nested_alias=, included, #nested_model_names_for_alias, #resolve_attributes_alias

Methods included from Zena::Acts::Enrollable::ModelMethods

#assigned_roles, #has_role?, included, #zafu_possible_roles

Methods included from Zena::Use::FieldIndex::ModelMethods

included, #property_field_index

Methods included from Zena::Use::MLIndex::ModelMethods

included, #index_reader, #rebuild_index_for_version, #rebuild_index_with_multi_lingual!

Methods included from Zena::Use::Kpath::InstanceMethods

included

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zena::Use::Relations::ModelMethods

Class Method Details

.accept_content_type?(content_type) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/template.rb', line 42

def accept_content_type?(content_type)
  content_type =~ /text\/(zafu)/
end

Instance Method Details

#filenameObject

Class Methods



47
48
49
# File 'app/models/template.rb', line 47

def filename
  "#{title}.#{ext}"
end

#rebuild_tkpath(rebuild_tklass = nil) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/models/template.rb', line 55

def rebuild_tkpath(rebuild_tklass = nil)
  if target_klass
    # this is a master template (found when choosing the template for rendering)
    if klass = rebuild_tklass
      # rebuilding index
      self.target_klass = klass.name
      self.tkpath       = klass.kpath
      self.title = title_from_mode_and_format
    elsif klass = VirtualClass[target_klass]
      self.tkpath = klass.kpath
    end
  else
    self.tkpath = nil
  end
end

#skinObject



51
52
53
# File 'app/models/template.rb', line 51

def skin
  @skin ||= secure(Skin) { Skin.find(skin_id) }
end