Sha256: 58c88db62df34cbb34a9a21f49b9f562a59fe7ff9ed966136dfb11aaf1a9cea2

Contents?: true

Size: 1.92 KB

Versions: 14

Compression:

Stored size: 1.92 KB

Contents

# encoding: UTF-8

# Copyright 2011 innoQ Deutschland GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module ApplicationHelper

  def iqvoc_default_rdf_namespaces
    Iqvoc.rdf_namespaces.merge({
        :default => root_url(:format => nil, :lang => nil, :trailing_slash => true).gsub(/\/\/$/, "/"), # gsub because of a Rails bug :-(
        :coll => collections_url(:trailing_slash => true, :lang => nil, :format => nil),
        :schema => controller.schema_url(:format => nil, :anchor => "", :lang => nil)
      })
  end

  def options_for_language_select(selected = nil)
    locales_collection = Iqvoc.available_languages.map { |l| [l.to_s, l.to_s] }

    options_for_select(locales_collection, selected)
  end

  def user_details(user)
    "#{user.name} (#{user.telephone_number})"
  end

  # Formats a list ob items or returns a remark if no items where given
  def item_listing(items, &block)
    return content_tag :p, "-", :class => 'term-unavailable' if items.empty?

    content_tag :ul, :class => "entity_list" do
      items.map do |item|
        content_tag :li, :class => (items.last == item ? "last-child" : "") do
          block.call(item)
        end
      end.join("\n").html_safe
    end
  end

  def error_messages_for(object)
    if object.errors.any?
      content_tag :ul, :class => "flash_error error_list" do
        object.errors.full_messages.each do |msg|
          concat(content_tag(:li, msg))
        end
      end
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
iqvoc-3.2.11 app/helpers/application_helper.rb
iqvoc-3.2.10 app/helpers/application_helper.rb
iqvoc-3.2.9 app/helpers/application_helper.rb
iqvoc-3.2.8 app/helpers/application_helper.rb
iqvoc-3.2.7 app/helpers/application_helper.rb
iqvoc-3.4.0 app/helpers/application_helper.rb
iqvoc-3.3.4 app/helpers/application_helper.rb
iqvoc-3.3.3 app/helpers/application_helper.rb
iqvoc-3.3.2 app/helpers/application_helper.rb
iqvoc-3.3.1 app/helpers/application_helper.rb
iqvoc-3.3.0 app/helpers/application_helper.rb
iqvoc-3.2.6 app/helpers/application_helper.rb
iqvoc-3.2.5 app/helpers/application_helper.rb
iqvoc-3.2.4 app/helpers/application_helper.rb