Commits

Michael Granger committed 066a603

Fix the toplevel index page in the content-manager.

- Special case the empty-path request
- Add Page#relative_html_path for cross-linking
- Strip off a leading '/' for PageCatalog patterns.

  • Participants
  • Parent commits 0fcdc8f

Comments (0)

Files changed (3)

File data/strelka-cms/apps/content-manager

 
 		# Force the path to be relative and clean it up
 		path = Pathname( path.gsub(%r{\A\.?/+|/(?=/)|/+\z}, '') )
+		page = nil
 
 		# Try to find a matching .page file
 		self.log.debug "Page path is: %p" % [ path ]
-		rcatalog = @catalog.relative_to( path.dirname ).
-			matching_pattern( "#{path.basename}{.page,/index.page}" )
-		if page = rcatalog.first
+		if path.to_s.empty?
+			subcat = @catalog.matching_pattern( 'index.page' )
+			page = subcat.first
+		else
+			subcat = @catalog.relative_to( path.dirname ).
+				matching_pattern( "#{path.basename(page.extname)}{.page,/index.page}" )
+			page = subcat.first
+		end
+
+		# If there was a matching .page file, use that
+		if page
 			self.log.debug "  found page: %p" % [ page ]
 			return self.page_response( page )
 		end

File lib/strelka/cms/page.rb

 	end
 
 
+	### Return the page's HTML path.
+	def relative_html_path
+		pagepath = self.relative_path or return nil
+		return pagepath.to_s.sub(/\.page$/, '.html')
+	end
+
+
 	### Apply the filters corresponding to the given +filter_names+ and return the modified
 	### +content+.
 	def apply_filters( content )

File lib/strelka/cms/pagecatalog.rb

 	### Create a new PageCatalog that will find and read pages from the configured
 	### directory.
 	def initialize( basedir=Pathname.pwd, pattern=DEFAULT_GLOB_PATTERN )
-		self.log.debug "New catalog for: %s/%s" % [ basedir.to_s.chomp('/'), pattern ]
+		pattern.slice!( 0, 1 ) if pattern.start_with?( '/' )
+		self.log.debug "New catalog for pages matching: %s in: %s" % [ pattern, basedir ]
 		@basedir  = Pathname( basedir )
 		@pageglob = pattern
 	end