Scrivito 1.2.0 Release Notes

Improvements

Renaming files

In editing mode, the files associated with binary attributes of CMS objects or widgets can now be renamed in the Content Browser if rendered in the details view using the scrivito_tag or scrivito_image_tag helper.

To disallow renaming a file, set the data-scrivito-editors-binary-filename option to false, like so:

<%= scrivito_tag(:div, @obj, :my_binary_attribute, data: {
  scrivito_editors_binary_filename: false,
  scrivito_editors_allow_delete: true
}) %>

See the Scrivito Editors Overview for further data attributes.

Content Browser supports tags 

For further narrowing down the CMS objects listed in the Content Browser, e.g. as the result of a search, you can now filter these objects by the tags associated with them. If, for example, you use tags as a means to categorize images by their prevailing colors, you can select the desired color combination to find the matching images.

A CMS object matches a tag-based search if at least all of the selected tags have been assigned to it.

To utilize tag filtering in the Content Browser, add a stringlist attribute named “tags” to those CMS object classes you want to support tagging:

class ProductPage < Obj
  …
  attribute :tags, :stringlist
  …
end

To make the tags of a CMS object editable, render the “tags” attribute in the details view of the object class using the standard helper:

<%= scrivito_tag(:div, @obj, :tags) %>

Editors for enum and multienum attributes

Scrivito now comes with brand new slick editors for attributes of the enum and multienum types:

Note that these editors previously needed to be clicked for activating them, whereas now they are always active in editing mode.

The corresponding editor is automatically made available as the scrivito_tag helper renders an enum or multienum attribute. However, if you'd like to continue using the select-tag-based editors for your enum and multienum attributes, add the following CoffeeScript snippets to your assets.

Show me the code
# select_editor.coffee:

template = (values) ->
  element = $('<select></select>')
    .addClass('form-control')

  $.each values, (index, value) ->
    $('<option></option>')
      .attr('value', value)
      .text(value)
      .appendTo(element)

  element

save = (event, options) ->
  element = $(event.currentTarget)
  cmsField = element.data('scrivitoEditorsCmsField')
  content = element.val()

  if content == ''
    content = null

  cmsField.scrivito('save', content).done ->
    cmsField.trigger 'scrivito_editors:save'
    if options?.blur
      cmsField.trigger 'scrivito_editors:blur'

change = (event) ->
  save event

blur = (event) ->
  save event, blur: true

activate = (element) ->
  cmsField = $(element)

  cmsField.on 'click', ->
    content = cmsField.scrivito('content')
    values = cmsField.scrivito('valid_values')
    values.unshift('')

    template(values)
      .data('scrivitoEditorsCmsField', cmsField)
      .val(content or '')
      .insertAfter(cmsField)
      .change(change)
      .blur(blur)
      .focus()

    cmsField.hide()

selectEditor =
  can_edit: (element) -> $(element).is '[data-scrivito-field-type=enum]'
  activate: (element) -> activate element

scrivito.on 'load', ->
  scrivito.define_editor 'select', selectEditor

# multi_select_editor.coffee:

template = (values) ->
  element = $('<select></select>')
    .attr('multiple', 'true')

  $.each values, (index, value) ->
    $('<option></option>')
      .attr('value', value)
      .text(value)
      .appendTo(element)

  element

save = (event) ->
  element = $(event.currentTarget)
  cmsField = element.data('cmsField')
  content = element.val() ? []
  cmsField.scrivito('save', content).done ->
    cmsField.trigger('save.scrivito_editors')

activate = (element) ->
  cmsField = $(element)

  cmsField.on 'click', ->
    selected = cmsField.scrivito('content')
    values = cmsField.scrivito('valid_values')

    template(values)
      .data('cmsField', cmsField)
      .val(selected)
      .insertAfter(cmsField)
      .change(save)
      .focusout(save)
      .focus()

    cmsField.hide()

multiSelectEditor =
  can_edit: (element) -> $(element).is '[data-scrivito-field-type=multienum]'
  activate: (element) -> activate element

scrivito.on 'load', ->
  scrivito.define_editor 'multi_select', multiSelectEditor

# make the select based editors active globally, by setting the scrivito.select_editor callback:

scrivito.select_editor (element, editing) ->
  if $(element).is("[data-scrivito-field-type=enum]")
    editing.use("select")
  if $(element).is("[data-scrivito-field-type=multienum]")
    editing.use("multi_select")

Improved widget usability

You can now easily insert a widget directly above or below a container widget using the plus buttons we added at the top and bottom edges of such widgets.

As a consequence, widget menus no longer include an “Insert widget” item. Also, as with other widgets, the handles of container widgets are now displayed at the top right corner.

Additionally, widgets can now be duplicated with a single click instead of having to copy and paste them: Widget menus now include an item for duplicating them.

Changelog

The changelog reflects minor improvements and bugfixes that were made in addition to the changes listed above.

Details

Minor improvements

  • Analogously to the widget generator, the page generator now enforces consistent page naming by appending the “page” part to the name if not specified:

    rails g scrivito:page Test1Page # generates app/models/test1_page.rb…
    rails g scrivito:page Test2 # generates app/models/test2_page.rb…
  • In addition to Scrivito.models.pages and Scrivito.models.widgets, which let you retrieve the defined *Page and, respectively, *Widget model classes, the Scrivito.models.objs method is now available. It returns all CMS object model classes, independently of whether they represent pages, binaries such as images, or custom object types. See the API documentation on Scrivito.models for details.
  • You can now use all Scrivito icons in the filter configuration of the Content Browser. See the documentation for a full list of icons.
  • Improvement for Chrome users: We eliminated two small visual glitches in the Scrivito panel and the Content Browser.
  • The Scrivito SDK is now fully thread-safe and can be used with multi-threaded servers such as Puma without hesitation.
  • The permalink editor now prevents the user from entering forbidden permalinks, e.g. "scrivito" or "scrivito/my_permalink." Also, if existing CMS objects have forbidden permalinks, Scrivito will not link to them but use their ID or slug instead.

Bugfixes

  • When a new parent CMS object, i.e. an object with children, was transferred to a different working copy (using the changes list), the transfer wasn't properly completed which caused the parent object to be present in both working copies. This bug has been fixed.
  • The slider editor now handles zero as its minimum and maximum values correctly, i.e. data-scrivito-editors-min=0 and data-scrivito-editors-max=0.
  • The stringlist editor now supports capital letters and commas in strings.