Module: Zena::Use::Display::ViewMethods
- Includes:
- RubyLess, ImageTags
- Defined in:
- lib/zena/use/display.rb
Overview
ImageTags
Constant Summary
Constants included from ImageTags
ImageTags::IMG_TAG_EXTRA_JS, ImageTags::IMG_TAG_EXTRA_RE
Instance Method Summary collapse
-
#admin_links(opts = {}) ⇒ Object
Return a list of administrative links.
-
#search_box(opts = {}) ⇒ Object
Display a search field.
-
#show_link(link, opt = {}) ⇒ Object
shows links for site features.
-
#sprintf_unless_zero(fmt, value) ⇒ Object
Return sprintf formated entry.
-
#start_node_zip ⇒ Object
Return the ‘zip’ of the node corresponding to the browser url (start node).
-
#uuid ⇒ Object
Return a random string that can be used as id (starts with a character).
Methods included from ImageTags
#asset_img_tag, #crop_formats, #generic_img_tag, #img_tag
Methods included from Common
Instance Method Details
#admin_links(opts = {}) ⇒ Object
Return a list of administrative links
263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/zena/use/display.rb', line 263 def admin_links(opts = {}) list = opts[:list] || 'all' if list == 'all' list = %w{home preferences comments jobs users groups relations virtual_classes properties iformats sites acls dev} else list = list.split(',').map(&:strip) end list = list.map do |key| show_link(key) end.compact list.empty? ? nil : list end |
#search_box(opts = {}) ⇒ Object
Display a search field
247 248 249 |
# File 'lib/zena/use/display.rb', line 247 def search_box(opts={}) render_to_string(:partial=>'search/form', :locals => {:ajax => opts[:ajax], :type => opts[:type]}) end |
#show_link(link, opt = {}) ⇒ Object
shows links for site features
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/zena/use/display.rb', line 279 def show_link(link, opt={}) case link when 'home' return nil if visitor.is_anon? link_to_with_state(_('my home'), user_path(visitor)) when 'preferences' return nil if visitor.is_anon? link_to_with_state(_('preferences'), preferences_user_path(visitor[:id])) when 'comments' return nil unless visitor.is_admin? link_to_with_state(_('comments'), comments_path) when 'users' return nil unless visitor.is_admin? link_to_with_state(_('users'), users_path) when 'groups' return nil unless visitor.is_admin? link_to_with_state(_('groups'), groups_path) when 'relations' return nil unless visitor.is_admin? link_to_with_state(_('relations'), relations_path) when 'virtual_classes' return nil unless visitor.is_admin? link_to_with_state(_('classes'), virtual_classes_path) when 'properties' return nil unless visitor.is_admin? link_to_with_state(_('properties'), columns_path) when 'iformats' return nil unless visitor.is_admin? link_to_with_state(_('image formats'), iformats_path) when 'sites' return nil unless visitor.is_admin? link_to_with_state(_('sites'), sites_path) when 'acls' return nil unless visitor.is_admin? link_to_with_state(_('acls'), acls_path) when 'jobs' return nil unless visitor.is_admin? && Bricks::CONFIG['worker'] link_to_with_state(_('jobs'), jobs_site_path(current_site[:id])) when 'dev' return nil unless visitor.is_admin? if visitor.dev_skin_id link_to(_('turn dev off'), dev_skin_path) else link_to(_('turn dev on'), dev_skin_path('skin_id' => '0')) end else nil end end |
#sprintf_unless_zero(fmt, value) ⇒ Object
Return sprintf formated entry. Return ” for values eq to zero.
242 243 244 |
# File 'lib/zena/use/display.rb', line 242 def sprintf_unless_zero(fmt, value) value.to_f == 0.0 ? '' : sprintf(fmt, value) end |
#start_node_zip ⇒ Object
Return the ‘zip’ of the node corresponding to the browser url (start node). This value is kept accross all Ajax calls.
258 259 260 |
# File 'lib/zena/use/display.rb', line 258 def start_node_zip (params[:s] || @node.zip).to_i end |
#uuid ⇒ Object
Return a random string that can be used as id (starts with a character)
252 253 254 |
# File 'lib/zena/use/display.rb', line 252 def uuid 'u' + UUIDTools::UUID.random_create.to_s.gsub('-','')[0..8] end |