Class: DefaultAction
- Inherits:
-
ViewAction
- Object
- WebAction
- ViewAction
- DefaultAction
- Includes:
- Localization
- Defined in:
- lib/ribit/action.rb
Overview
This action is the default action that is responsible for creating a page when no specific action is defined by request URL. The action views the main page defined in Ribit configuration file.
Constant Summary
Constants included from Localization
Localization::ACTION_CATEGORY_CREATION_NOTICE, Localization::ACTION_DEFAULT_PAGE_FAILED, Localization::ACTION_EDIT_CANCELED, Localization::ACTION_NEW_PAGE_OK, Localization::ACTION_SAVE_CATEGORY_OK, Localization::ACTION_SAVE_OK, Localization::NO_PARENT_OPTION, Localization::TITLE_CATEGORIES_PAGE, Localization::TITLE_NEW_CATEGORY, Localization::TITLE_NEW_PAGE
Constants inherited from ViewAction
Instance Attribute Summary
Attributes inherited from WebAction
Instance Method Summary collapse
- #get_page_id(pageRequest) ⇒ Object
-
#initialize(ribitData, ribitConfig, pageCache) ⇒ DefaultAction
constructor
A new instance of DefaultAction.
- #run(pageRequest, pageResponse) ⇒ Object
Methods included from Localization
#get_localized, #ribitData_defined?
Methods inherited from ViewAction
#decorate_page, #get_cached_page
Methods included from Assert
assert, #assert, assert_nil, #assert_nil, #assert_not_nil, assert_not_nil, raise_exception
Methods inherited from WebAction
Constructor Details
#initialize(ribitData, ribitConfig, pageCache) ⇒ DefaultAction
Returns a new instance of DefaultAction.
542 543 544 545 546 547 548 549 |
# File 'lib/ribit/action.rb', line 542 def initialize( ribitData, ribitConfig, pageCache ) super( ribitData, ribitConfig, pageCache ) @id = 'default' @logger = RibitLogger.new( DefaultAction ) @ribitData = ribitData @defaultPageID = nil end |
Instance Method Details
#get_page_id(pageRequest) ⇒ Object
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
# File 'lib/ribit/action.rb', line 575 def get_page_id( pageRequest ) if ( @defaultPageID == nil ) mainPageRef = @ribitConfig[RibitConfig::MAIN_PAGE] # first we try by name page = @ribitData.get_page_by_full_name( mainPageRef ) if ( page == nil ) page = @ribitData.get_page_by_id( mainPageRef ) end if ( page == nil ) raise RibitException, "No default page found: #{mainPageRef}", caller end @defaultPageID = page.full_id @logger.debug( "The default page is: name=#{page.full_name}, pageID=#{@defaultPageID}" ) end return @defaultPageID end |
#run(pageRequest, pageResponse) ⇒ Object
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/ribit/action.rb', line 552 def run( pageRequest, pageResponse ) begin super( pageRequest, pageResponse ) rescue RibitException => exception @logger.error( 'Showing default page failed' ) @logger.error( format_exception( exception ) ) # probable reason was that default page was not found # => show categories page # => if that throws error too then upper level takes care of it # TODO: caching of this page ?? should reuse view categories action ?? @logger.info( 'Because default page failed showing Categories page' ); page = CategoriesPage.new( @ribitData, @ribitConfig ) page.( get_localized( ACTION_DEFAULT_PAGE_FAILED, { 'message' => exception. } ) ) decorate_page( page ) page.output_page( pageResponse ) end end |