Permalink
Browse files

Create page if no match is found when using _go

This was a usability issue pointed out by a non-technical user.
There seemed to be no obvious way to create new pages. This was
the suggested solution and the easiest to implement.
  • Loading branch information...
joehillen committed Jan 1, 2014
1 parent 9082dc1 commit 1328545e1b9e86132b4937ac5fb2afc314bb0758
Showing with 2 additions and 6 deletions.
  1. +2 −6 Network/Gitit/Handlers.hs
@@ -242,19 +242,15 @@ goToPage = withData $ \(params :: Params) -> do
let findPage f = find f allPageNames
let exactMatch f = gotopage == f
let insensitiveMatch f = (map toLower gotopage) == (map toLower f)
let prefixMatch f = (map toLower gotopage) `isPrefixOf` (map toLower f)
base' <- getWikiBase
case findPage exactMatch of
Just m -> seeOther (base' ++ urlForPage m) $ toResponse
"Redirecting to exact match"
Nothing -> case findPage insensitiveMatch of
Just m -> seeOther (base' ++ urlForPage m) $ toResponse
"Redirecting to case-insensitive match"
Nothing -> case findPage prefixMatch of
Just m -> seeOther (base' ++ urlForPage m) $
toResponse $ "Redirecting" ++
" to partial match"
Nothing -> searchResults
Nothing -> seeOther (base' ++ urlForPage gotopage) $ toResponse
"Redirecting to new page"
searchResults :: Handler
searchResults = withData $ \(params :: Params) -> do

0 comments on commit 1328545

Please sign in to comment.