app/helpers/scrivito_helper.rb in scrivito_sdk-1.5.5 vs app/helpers/scrivito_helper.rb in scrivito_sdk-1.6.0.rc1
- old
+ new
@@ -37,10 +37,13 @@
# @option editing_options [String, Symbol] :editor Name of the JavaScript editor to be used for
# this field. Normally, the name of the editor to be used for a field is determined by the
# +scrivito.select_editor+ JavaScript API. The option +:editor+ should only be used if setting
# the editor via the JavaScript API is not feasible. Specifying +editor: false+ disables
# in-place editing.
+ # @option editing_options [Boolean] :disable_margins If +true+, no margins are attached to the
+ # widgets contained in a +widgetlist+ attribute. In this case, the in-place editing controls of
+ # widgets may overlap which can be handled by using suitable CSS. Defaults to +false+.
#
# @param block [Proc] Optional block to render inner HTML. If none given the value of attribute
# will be rendered instead. +block+ is not allowed for fields of type +widget+.
#
# @raise ArgumentError if the field behind +field_name+ is of type +widget+ and a +block+ is given.
@@ -260,12 +263,12 @@
#
# @param title [String] title of the thumbnail, e.g. "Content Page" or "Image Widget".
# @param icon [Symbol, String] icon of the thumbnail.
# You can use one of the built-in icons or specify your own HTML.
# There are following built-in icons: +:content+, +:headline+, +:image+, +:scrivito+ and +:text+.
- # If the name of the specyfied icon is unknown, then the default icon (+:scrivito+) will be displayed.
- # If you are speifying your own HTML string, then make sure it is HTML safe.
+ # If the name of the specified icon is unknown, then the default icon (+:scrivito+) will be displayed.
+ # If you are specifying your own HTML string, then make sure it is HTML safe.
# @param block [Proc] the description of the thumbnail.
#
# @example A simple thumbnail
# scrivito_thumbnail('Content Page') do
# 'A content page.'
@@ -291,15 +294,20 @@
text: '',
}.fetch(icon, '')
icon = content_tag(:i, icon_code.html_safe, class: 'scrivito_icon')
end
- content_tag(:div, class: 'scrivito_editing_widget_preview') do
+ content_tag(:div, 'data-scrivito-private-thumbnail-title' => title) do
capture do
concat content_tag(:div, icon, class: 'scrivito_editing_widget_visualization')
concat content_tag(:div, title, class: 'scrivito_editing_widget_title')
- concat content_tag(:div, class: 'scrivito_editing_widget_description', &block)
+
+ if block_given?
+ concat content_tag(:div, class: 'scrivito_editing_widget_description', &block)
+ else
+ concat content_tag(:div, nil, class: 'scrivito_editing_widget_description')
+ end
end
end
end
#
@@ -383,19 +391,24 @@
def scrivito_head_tags
layout_tags = Scrivito::LayoutTags.new(self)
capture do
concat layout_tags.editing_auth_warning
concat layout_tags.generator_meta_tag
+ if scrivito_user
+ concat javascript_include_tag('scrivito_ui_redirect')
+ end
end
end
#
# Renders all tags needed in the HTML body.
# @api public
#
def scrivito_body_tags
- Scrivito::LayoutTags.new(self).page_config(@obj)
+ if scrivito_user
+ Scrivito::LayoutTags.new(self).page_config(@obj)
+ end
end
{
'cms_image_tag' => 'scrivito_image_tag',
'cms_path' => 'scrivito_path',
@@ -458,8 +471,46 @@
# <% end %>
#
def scrivito_widget_tag(html_options, &block)
capture(&block).tap do
@scrivito_widget_tag_html_options = html_options
+ end
+ end
+
+ #
+ # The +scrivito_backlinks+ helper generates HTML markup for the list of
+ # {Scrivito::Associations#backlinks backlinks} of a given CMS object.
+ #
+ # @api public
+ #
+ # The helper is intended to be used on details views. The DOM structure it generates and the CSS
+ # classes it uses are compatible with the CSS of the SDK. This helper ensures that backlink lists
+ # fit into the design the SDK applies.
+ #
+ # @param obj [Scrivito::BasicObj] an +Obj+ whose backlinks should be rendered.
+ #
+ # @example
+ # scrivito_details_for "Backlinks:" do
+ # scrivito_backlinks @obj
+ # end
+ #
+ # @see Scrivito::Associations#backlinks
+ #
+ def scrivito_backlinks(obj)
+ content_tag(:div, class: 'scrivito_backlinks_list') do
+ backlinks = obj.backlinks.to_a
+
+ if backlinks.any?
+ content_tag(:ul) do
+ capture do
+ backlinks.each do |o|
+ concat(content_tag(:li) {
+ concat(content_tag(:i, nil, class: 'scrivito_icon scrivito_icon_link'))
+ concat(link_to(o.description_for_editor, scrivito_path(o), target: :_blank))
+ })
+ end
+ end
+ end
+ end
end
end
end