Class: RibitLinkContainer
- Defined in:
- lib/ribit/contentparser.rb
Instance Method Summary collapse
-
#initialize(linkData, contentDoc) ⇒ RibitLinkContainer
constructor
A new instance of RibitLinkContainer.
- #to_s ⇒ Object
Methods inherited from Container
#<<, #add_child, #childs?, #get_childs, #get_parent, #replace, #set_childs, #text?
Methods included from Assert
assert, #assert, assert_nil, #assert_nil, #assert_not_nil, assert_not_nil, raise_exception
Constructor Details
#initialize(linkData, contentDoc) ⇒ RibitLinkContainer
Returns a new instance of RibitLinkContainer.
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
# File 'lib/ribit/contentparser.rb', line 981 def initialize( linkData, contentDoc ) super( nil ) @logger = RibitLogger.new( RibitLinkContainer ) if ( /\|/.match( linkData ) ) # yes, there is link description splitData = linkData.split( '|' ) linkData = splitData[0] linkDescription = splitData[1] else linkDescription = linkData end # does linkData contain category ref ? if ( /::/.match( linkData ) ) # yes, it does => split data splitData = linkData.split( '::' ) pageName = splitData[ splitData.size - 1 ] categoryFullName = splitData[0..(splitData.size - 2 )].join( '::' ) # if link ends to | then we show just page name if ( linkDescription == nil or linkDescription.strip.size == 0 ) linkDescription = pageName end else # no category => use default categoryFullName = contentDoc.get_current_category().full_name pageName = linkData if ( linkDescription == nil or linkDescription.strip.size == 0 ) linkDescription = pageName end end ribitData = contentDoc.get_ribitdata # first try with full name (assuming categoryFullName is really full name) targetPage = ribitData.get_page_by_full_name( categoryFullName + "::" + pageName ) #puts "searching: " + categoryFullName + "::" + pageName # .. then if not found try partial name if ( targetPage == nil ) newCategoryFullName = contentDoc.get_current_category().full_name + '::' + categoryFullName newCandinate = newCategoryFullName + "::" + pageName targetPage = ribitData.get_page_by_full_name( newCandinate ) if ( targetPage != nil ) categoryFullName = newCategoryFullName end end if ( targetPage == nil ) # page doesn't exist => link for creating new action = EditNewActionAdapter.new( categoryFullName, pageName, contentDoc.get_current_page_full_id ) url = action.get_url link1 = LinkTag.new( url, '[', false ) link2 = LinkTag.new( url, ']', false ) @logger.debug( 'link1=' + link1.to_s ) @text = link1.to_s + linkDescription + link2.to_s @logger.debug( 'text=' + @text ) else # page exists so put just page id action = ViewActionAdapter.new( targetPage.full_id ) @text = LinkTag.new( action.get_url, linkDescription, false ).to_s end end |
Instance Method Details
#to_s ⇒ Object
1053 1054 1055 |
# File 'lib/ribit/contentparser.rb', line 1053 def to_s return @text end |