Class: Caboose::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::PagesController
- Defined in:
- app/controllers/caboose/pages_controller.rb
Instance Method Summary collapse
- #admin_block_options_helper(options, b, prefix) ⇒ Object
- #admin_create ⇒ Object
- #admin_delete ⇒ Object
- #admin_delete_form ⇒ Object
- #admin_duplicate ⇒ Object
- #admin_duplicate_form ⇒ Object
- #admin_edit_block_order ⇒ Object
- #admin_edit_child_sort_order ⇒ Object
- #admin_edit_content ⇒ Object
- #admin_edit_css ⇒ Object
- #admin_edit_custom_fields ⇒ Object
- #admin_edit_general ⇒ Object
- #admin_edit_js ⇒ Object
- #admin_edit_layout ⇒ Object
- #admin_edit_permissions ⇒ Object
- #admin_edit_seo ⇒ Object
- #admin_hide_page ⇒ Object
- #admin_index ⇒ Object
- #admin_new ⇒ Object
- #admin_new_blocks ⇒ Object
- #admin_options ⇒ Object
- #admin_page_uri ⇒ Object
- #admin_parent_block_options_helper(options, b, prefix, this_block) ⇒ Object
- #admin_show_page ⇒ Object
- #admin_sitemap ⇒ Object
- #admin_update ⇒ Object
- #admin_update_block_order ⇒ Object
- #admin_update_child_permissions ⇒ Object
- #admin_update_child_sort_order ⇒ Object
- #admin_update_layout ⇒ Object
- #asset ⇒ Object
- #before_action ⇒ Object
- #redirect ⇒ Object
- #show ⇒ Object
- #sitemap_helper(page, options, prefix = '') ⇒ Object
Methods inherited from ApplicationController
#add_ga_event, #admin_add, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_edit, #admin_json, #admin_json_single, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #under_construction_or_forwarding_domain?, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_block_options_helper(options, b, prefix) ⇒ Object
707 708 709 710 711 712 |
# File 'app/controllers/caboose/pages_controller.rb', line 707 def (, b, prefix) << { 'value' => b.id, 'text' => "#{prefix}#{b.title}" } b.children.each do |b2| (, b2, "#{prefix} - ") end end |
#admin_create ⇒ Object
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
# File 'app/controllers/caboose/pages_controller.rb', line 449 def admin_create return unless user_is_allowed('pages', 'add') resp = Caboose::StdClass.new({ 'error' => nil, 'redirect' => nil }) parent_id = params[:parent_id] title = params[:title] if (title.strip.length == 0) resp.error = "A page title is required." elsif (!logged_in_user.is_allowed('all', 'all') && !Page.(logged_in_user, 'edit' ).include?(parent_id) && !Page.(logged_in_user, 'approve').include?(parent_id)) resp.error = "You don't have permission to add a page there." end if (!resp.error.nil?) render :json => resp return end parent = Caboose::Page.find(parent_id) page = Caboose::Page.new if parent.nil? d = Domain.where(:domain => request.host_with_port).first.site_id page.site_id = d.site_id else page.site_id = parent.site_id end page.title = title page.parent_id = parent_id page.hide = true page.content_format = Caboose::Page::CONTENT_FORMAT_HTML page.save i = 0 begin page.slug = Page.slug(page.title + (i > 0 ? " #{i}" : "")) page.uri = parent.parent_id == -1 ? page.slug : "#{parent.uri}/#{page.slug}" i = i+1 end while (Page.where(:uri => page.uri, :site_id => page.site_id).count > 0 && i < 10) page.save # Create the top level block for the page bt = BlockType.find(params[:block_type_id]) Block.create(:page_id => page.id, :block_type_id => params[:block_type_id], :name => bt.name) # Set the new page's permissions viewers = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'view' }).pluck(:role_id) editors = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'edit' }).pluck(:role_id) Caboose::Page.(page.id, 'view', viewers) Caboose::Page.(page.id, 'edit', editors) # Send back the response resp.redirect = "/admin/pages/#{page.id}" render json: resp end |
#admin_delete ⇒ Object
635 636 637 638 639 640 641 642 643 |
# File 'app/controllers/caboose/pages_controller.rb', line 635 def admin_delete return unless user_is_allowed('pages', 'delete') p = Page.find(params[:id]) p.destroy resp = StdClass.new({ 'redirect' => '/admin/pages' }) render json: resp end |
#admin_delete_form ⇒ Object
408 409 410 411 412 413 414 415 416 |
# File 'app/controllers/caboose/pages_controller.rb', line 408 def admin_delete_form return unless user_is_allowed('pages', 'delete') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_duplicate ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'app/controllers/caboose/pages_controller.rb', line 384 def admin_duplicate return unless user_is_allowed('pages', 'add') resp = Caboose::StdClass.new p = Page.where(:id => params[:id]).first site_id = params[:site_id] parent_id = params[:parent_id] block_type_id = params[:block_type_id] child_block_type_id = params[:child_block_type_id] duplicate_children = params[:duplicate_children] == 'true' ? true : false if p.nil? then resp.error = "Invalid page" elsif site_id.nil? then resp.error = "Invalid site" elsif parent_id.nil? then resp.error = "Invalid parent" else resp.new_id = p.delay(:priority => 20).duplicate(site_id, parent_id, duplicate_children, block_type_id, child_block_type_id) resp.success = true end render :json => resp end |
#admin_duplicate_form ⇒ Object
373 374 375 376 377 378 379 380 381 |
# File 'app/controllers/caboose/pages_controller.rb', line 373 def admin_duplicate_form return unless user_is_allowed('pages', 'add') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_block_order ⇒ Object
288 289 290 291 292 |
# File 'app/controllers/caboose/pages_controller.rb', line 288 def admin_edit_block_order return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) render :layout => 'caboose/admin' end |
#admin_edit_child_sort_order ⇒ Object
347 348 349 350 351 352 353 354 355 |
# File 'app/controllers/caboose/pages_controller.rb', line 347 def admin_edit_child_sort_order return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_content ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 |
# File 'app/controllers/caboose/pages_controller.rb', line 199 def admin_edit_content @page = Page.find(params[:id]) redirect_to "/login?return_url=/admin/pages/#{@page.id}/content" and return if @logged_in_user.nil? condition = @logged_in_user && (@logged_in_user.is_super_admin? || (@logged_in_user.site_id == @page.site_id && ( @logged_in_user.is_allowed('all','all') || @logged_in_user.is_allowed('pages','edit') && Page.permissible_actions(@logged_in_user, @page.id).include?('edit')))) redirect_to "/admin/pages" and return unless condition if @page.block.nil? redirect_to "/admin/pages/#{@page.id}/layout" return end @editing = true end |
#admin_edit_css ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'app/controllers/caboose/pages_controller.rb', line 314 def admin_edit_css return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_custom_fields ⇒ Object
170 171 172 173 174 175 |
# File 'app/controllers/caboose/pages_controller.rb', line 170 def admin_edit_custom_fields return if !user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) @page.verify_custom_field_values_exist render :layout => 'caboose/modal' end |
#admin_edit_general ⇒ Object
437 438 439 440 441 442 443 444 445 446 |
# File 'app/controllers/caboose/pages_controller.rb', line 437 def admin_edit_general return if !user_is_allowed('pages', 'edit') #return if !Page.is_allowed(logged_in_user, params[:id], 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_js ⇒ Object
325 326 327 328 329 330 331 332 333 |
# File 'app/controllers/caboose/pages_controller.rb', line 325 def admin_edit_js return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_layout ⇒ Object
212 213 214 215 216 217 218 219 220 |
# File 'app/controllers/caboose/pages_controller.rb', line 212 def admin_edit_layout return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_permissions ⇒ Object
178 179 180 181 182 183 184 185 186 |
# File 'app/controllers/caboose/pages_controller.rb', line 178 def return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_edit_seo ⇒ Object
336 337 338 339 340 341 342 343 344 |
# File 'app/controllers/caboose/pages_controller.rb', line 336 def admin_edit_seo return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_hide_page ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'app/controllers/caboose/pages_controller.rb', line 238 def admin_hide_page return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else @page.hide = true @page.save resp.success = true end render :json => resp end |
#admin_index ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'app/controllers/caboose/pages_controller.rb', line 150 def admin_index return if !user_is_allowed('pages', 'view') @user = @logged_in_user @domain = Domain.where(:domain => request.host_with_port).first @home_page = @domain ? Page.index_page(@domain.site_id) : nil if @domain && @home_page.nil? @home_page = Caboose::Page.create(:site_id => @domain.site_id, :parent_id => -1, :title => 'Home') end render :layout => 'caboose/admin' end |
#admin_new ⇒ Object
162 163 164 165 166 167 |
# File 'app/controllers/caboose/pages_controller.rb', line 162 def admin_new return unless user_is_allowed('pages', 'add') @parent_id = params[:parent_id] ? params[:parent_id] : Page.where(:site_id => @site.id, :parent_id => -1).first.id @parent = Page.find(@parent_id) render :layout => 'caboose/admin' end |
#admin_new_blocks ⇒ Object
307 308 309 310 311 |
# File 'app/controllers/caboose/pages_controller.rb', line 307 def admin_new_blocks return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) render :layout => 'caboose/admin' end |
#admin_options ⇒ Object
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'app/controllers/caboose/pages_controller.rb', line 648 def if !user_is_allowed('pages', 'edit') render :json => false return end case params[:field] when nil when 'sitemap' parent_id = params[:parent_id] p = nil if params[:site_id] && logged_in_user.is_super_admin? p = parent_id ? Page.find(parent_id) : Page.index_page(params[:site_id].to_i) else p = parent_id ? Page.find(parent_id) : Page.index_page(@site.id) end = [] if p sitemap_helper(p, ) end when 'robots' = [ { 'value' => 'index' , 'text' => 'index' }, { 'value' => 'noindex' , 'text' => 'noindex' }, { 'value' => 'follow' , 'text' => 'follow' }, { 'value' => 'nofollow' , 'text' => 'nofollow' }, { 'value' => 'nosnippet' , 'text' => 'nosnippet' }, { 'value' => 'noodp' , 'text' => 'noodp' }, { 'value' => 'noarchive' , 'text' => 'noarchive' } ] when 'format' = [ { 'value' => 'html', 'text' => 'html' }, { 'value' => 'text', 'text' => 'text' }, { 'value' => 'ruby', 'text' => 'ruby' } ] when 'block' = [] Block.where("parent_id is null and page_id = ?", params[:id]).reorder(:sort_order).all.each do |b| (, b, "") end when 'parentblock' = [] this_block = Block.find(params[:block_id]) Block.where("parent_id is null and page_id = ?", params[:id]).reorder(:sort_order).all.each do |b| (, b, "", this_block) end end render :json => end |
#admin_page_uri ⇒ Object
419 420 421 422 423 |
# File 'app/controllers/caboose/pages_controller.rb', line 419 def admin_page_uri return unless user_is_allowed('pages', 'view') p = Page.find(params[:id]) render :json => { 'uri' => p.uri } end |
#admin_parent_block_options_helper(options, b, prefix, this_block) ⇒ Object
714 715 716 717 718 719 720 721 |
# File 'app/controllers/caboose/pages_controller.rb', line 714 def (, b, prefix, this_block) if b.block_type.allow_child_blocks && (b.block_type.default_child_block_type_id.blank? || b.block_type.default_child_block_type_id == this_block.block_type_id) << { 'value' => b.id, 'text' => "#{prefix}#{b.title}" } end b.children.each do |b2| (, b2, "#{prefix} - ", this_block) end end |
#admin_show_page ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'app/controllers/caboose/pages_controller.rb', line 223 def admin_show_page return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else @page.hide = false @page.save resp.success = true end render :json => resp end |
#admin_sitemap ⇒ Object
426 427 428 429 430 431 432 433 434 |
# File 'app/controllers/caboose/pages_controller.rb', line 426 def admin_sitemap return unless user_is_allowed('pages', 'delete') @page = Page.find(params[:id]) if @page.site_id != @logged_in_user.site_id && !@logged_in_user.is_super_admin? redirect_to '/admin/pages' else render :layout => 'caboose/admin' end end |
#admin_update ⇒ Object
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
# File 'app/controllers/caboose/pages_controller.rb', line 513 def admin_update return unless user_is_allowed('pages', 'edit') resp = StdClass.new({'attributes' => {}}) page = Page.find(params[:id]) save = true user = logged_in_user params.each do |name, value| case name when 'parent_id' value = value.to_i if page.id == value resp.error = "The page's parent cannot be itself." elsif Page.is_child(page.id, value) resp.error = "You can't set the current page's parent to be one of its child pages." elsif value != page.parent_id p = Page.find(value) if !user.is_allowed(p, 'edit') resp.error = "You don't have access to put the current page there." end end if resp.error save = false else page.parent = Page.find(value) page.save Page.update_uri(page) resp.attributes['parent_id'] = { 'text' => page.parent.title } end when 'custom_css', 'custom_css_files', 'custom_js', 'custom_js_files' value.strip! page[name.to_sym] = value when 'title', 'menu_title', 'hide', 'layout', 'redirect_url', 'seo_title', 'meta_keywords', 'meta_description', 'fb_description', 'gp_description', 'canonical_url' page[name.to_sym] = value when 'linked_resources' result = [] value.each_line do |line| line.chomp! line.strip! next if line.empty? if !(line.ends_with('.js') || line.ends_with('.css')) resp.error = "Resource '#{line}' has an unsupported file type ('#{comps.last}')." save = false end result << line end page.linked_resources = result.join("\n") when 'content_format' page.content_format = value resp.attributes['content_format'] = { 'text' => value } when 'meta_robots' arr = value.split(',').collect { |v| v.strip } if arr.include?('index') && arr.include?('noindex') resp.error = "You can't have both index and noindex" save = false elsif arr.include?('follow') && arr.include?('nofollow') resp.error = "You can't have both follow and nofollow" save = false else page. = arr.join(', ') resp.attributes['meta_robots'] = { 'text' => page. } end when 'content' page.content = value.strip.gsub(/<meta.*?>/, '').gsub(/<link.*?>/, '').gsub(/\<\!--[\S\s]*?--\>/, '') when 'slug' page.slug = Page.slug(value.strip.length > 0 ? value : page.title) page.save Page.update_uri(page) resp.attributes['slug'] = { 'value' => page.slug } resp.attributes['uri'] = { 'value' => page.uri } when 'alias' page.alias = Page.slug(value.strip) page.save Page.update_uri(page) resp.attributes['slug'] = { 'value' => page.slug } resp.attributes['uri'] = { 'value' => page.uri } when 'custom_sort_children' if (value == 0) page.children.each do |p| p.sort_order = 1 p.save end end page.custom_sort_children = value when 'viewers' Page.(page.id, 'view', value) when 'editors' Page.(page.id, 'edit', value) when 'approvers' Page.(page.id, 'approve', value) when 'tags' = page..collect{ |t| t.tag } = value.split(',').collect{ |v| v.strip.downcase }.reject{ |t| t.nil? || t.strip.length == 0 } # Delete the tags not in new_tags .each{ |t| PageTag.where(:page_id => page.id, :tag => t).destroy_all if !.include?(t) } # Add any new tags not in current_tags .each{ |t| PageTag.create(:page_id => page.id, :tag => t) if !.include?(t) } end end resp.success = save && page.save render json: resp end |
#admin_update_block_order ⇒ Object
295 296 297 298 299 300 301 302 303 304 |
# File 'app/controllers/caboose/pages_controller.rb', line 295 def admin_update_block_order return unless user_is_allowed('pages', 'edit') block_ids = params[:block_ids] i = 0 block_ids.each do |block_id| Block.find(block_id).update_attribute(:sort_order, i) i = i + 1 end render :json => true end |
#admin_update_child_permissions ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'app/controllers/caboose/pages_controller.rb', line 189 def return unless user_is_allowed('pages', 'edit') page = Page.find(params[:id]) if page Page.update_child_perms(page.id) end render :json => { :success => true } end |
#admin_update_child_sort_order ⇒ Object
358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'app/controllers/caboose/pages_controller.rb', line 358 def admin_update_child_sort_order return unless user_is_allowed('pages', 'edit') @page = Page.find(params[:id]) page_ids = params[:page_ids] i = 0 page_ids.each do |pid| p = Page.find(pid) p.sort_order = i p.save i = i + 1 end render :json => true end |
#admin_update_layout ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'app/controllers/caboose/pages_controller.rb', line 253 def admin_update_layout return unless user_is_allowed('pages', 'edit') bt = BlockType.find(params[:block_type_id]) old_block = Block.where(:page_id => params[:id], :parent_id => nil).first old_block_ids = Block.where(:page_id => params[:id]).pluq(:id) new_block = Block.create(:page_id => params[:id], :block_type_id => params[:block_type_id], :name => bt.name) new_block.create_children saved_blocks = [] if new_block && old_block && new_block.child('content') && old_block.child('content') old_content = old_block.child('content') new_content = new_block.child('content') old_content.children.each do |child| child.parent_id = new_content.id child.save saved_blocks << child.id child.children.each do |c1| saved_blocks << c1.id c1.children.each do |c2| saved_blocks << c2.id c2.children.each do |c3| saved_blocks << c3.id end end end end end where1 = saved_blocks.count > 0 ? "id NOT IN (#{saved_blocks.to_s.gsub('[','').gsub(']','')})" : '' Block.where(:id => old_block_ids).where(where1).destroy_all resp = Caboose::StdClass.new({ 'redirect' => "/admin/pages/#{params[:id]}/content" }) render :json => resp end |
#asset ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'app/controllers/caboose/pages_controller.rb', line 90 def asset uri = uri.to_s.gsub(/^(.*?)\?.*?$/, '\1') uri.chop! if uri.end_with?('/') uri[0] = '' if uri.starts_with?('/') page = Page.page_with_uri(request.host_with_port, File.dirname(uri), false) if page.nil? || !page # Check for a 301 redirect site_id = Site.id_for_domain(request.host_with_port) new_url = PermanentRedirect.match(site_id, request.fullpath) if new_url redirect_to new_url, :status => 301 return end respond_to do |format| format.all { render :file => "caboose/extras/error404", :layout => "caboose/application", :formats => [:html] } end return end asset = Asset.where(:page_id => page.id, :filename => File.basename(uri)).first if (asset.nil?) respond_to do |format| format.all { render :file => "caboose/extras/error404", :layout => "caboose/application", :formats => [:html] } end return end user = logged_in_user if (!Page.is_allowed(user, asset.page_id, 'view')) render "caboose/pages/asset_no_permission" return end #Caboose.log(Caboose::assets_path, 'Caboose::assets_path') path = Caboose::assets_path.join("#{asset.id}.#{asset.extension}") #Caboose.log("Sending asset #{path}") #send_file(path) #send_file(path, :filename => "your_document.pdf", :type => "application/pdf") # #$path = ASSETS_PATH ."/". $asset->id .".". $asset->extension # #$finfo = finfo_open(FILEINFO_MIME_TYPE) // return mime type ala mimetype extension #$mime = finfo_file($finfo, $path) #finfo_close($finfo) # #header("X-Sendfile: $path") #header("Content-Type: $mime") #header("Content-Disposition: inline filename=\"$asset->filename\"") end |
#before_action ⇒ Object
7 8 9 |
# File 'app/controllers/caboose/pages_controller.rb', line 7 def before_action @page = Page.page_with_uri(request.host_with_port, '/admin') end |
#redirect ⇒ Object
12 13 14 15 |
# File 'app/controllers/caboose/pages_controller.rb', line 12 def redirect @page = Page.find(params[:id]) redirect_to "/#{@page.uri}" end |
#show ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/caboose/pages_controller.rb', line 18 def show # Find the page with an exact URI match page = Page.page_with_uri(request.host_with_port, request.fullpath, false) # Make sure we're not under construction or on a forwarded domain d = Caboose::Domain.where(:domain => request.host_with_port).first if d.nil? Caboose.log("Could not find domain for #{request.host_with_port}\nAdd this domain to the caboose site.") elsif d.under_construction == true if d.site.under_construction_html && d.site.under_construction_html.strip.length > 0 render :text => d.site.under_construction_html else render :file => 'caboose/application/under_construction', :layout => false end return # See if we're on a forwarding domain elsif d.primary == false && d.forward_to_primary == true pd = d.site.primary_domain if pd && pd.domain != request.host url = "#{request.protocol}#{pd.domain}" if d.forward_to_uri && d.forward_to_uri.strip.length > 0 url << d.forward_to_uri elsif request.fullpath && request.fullpath.strip.length > 0 && request.fullpath.strip != '/' url << request.fullpath end redirect_to url return end elsif d.primary == false && !d.forward_to_uri.blank? && request.fullpath == '/' url = "#{request.protocol}#{d.domain}#{d.forward_to_uri}" redirect_to url return elsif d.force_ssl == true && request.protocol != 'https://' && Rails.env.production? url = "https://#{d.domain}#{request.fullpath}" redirect_to url return end if !page asset return end user = logged_in_user if !user.is_allowed(page, 'view') if user.id == User.logged_out_user_id(@site.id) redirect_to "/modal/login?return_url=" + URI.encode(request.fullpath) return else # go to 404 page render :file => "caboose/extras/error404", :layout => "caboose/application", :formats => [:html] end end if session['use_redirect_urls'] && !page.redirect_url.nil? && page.redirect_url.strip.length > 0 redirect_to page.redirect_url return end page = Caboose.plugin_hook('page_content', page) @page = page @user = user @editmode = !params['edit'].nil? && user.is_allowed('pages', 'edit') ? true : false # @crumb_trail = Caboose::Page.crumb_trail(@page) # @subnav = Caboose::Page.subnav(@page, session['use_redirect_urls'], @user) #@subnav.links = @tasks.collect {|href, task| {'href' => href, 'text' => task, 'is_current' => uri == href}} end |
#sitemap_helper(page, options, prefix = '') ⇒ Object
700 701 702 703 704 705 |
# File 'app/controllers/caboose/pages_controller.rb', line 700 def sitemap_helper(page, , prefix = '') << { 'value' => page.id, 'text' => prefix + page.title } page.children.each do |kid| sitemap_helper(kid, , prefix + ' - ') end end |