Skip to content

Commit

Permalink
Create page if no match is found when using _go
Browse files Browse the repository at this point in the history
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 1328545
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Network/Gitit/Handlers.hs
Expand Up @@ -242,19 +242,15 @@ goToPage = withData $ \(params :: Params) -> do
let findPage f = find f allPageNames let findPage f = find f allPageNames
let exactMatch f = gotopage == f let exactMatch f = gotopage == f
let insensitiveMatch f = (map toLower gotopage) == (map toLower f) let insensitiveMatch f = (map toLower gotopage) == (map toLower f)
let prefixMatch f = (map toLower gotopage) `isPrefixOf` (map toLower f)
base' <- getWikiBase base' <- getWikiBase
case findPage exactMatch of case findPage exactMatch of
Just m -> seeOther (base' ++ urlForPage m) $ toResponse Just m -> seeOther (base' ++ urlForPage m) $ toResponse
"Redirecting to exact match" "Redirecting to exact match"
Nothing -> case findPage insensitiveMatch of Nothing -> case findPage insensitiveMatch of
Just m -> seeOther (base' ++ urlForPage m) $ toResponse Just m -> seeOther (base' ++ urlForPage m) $ toResponse
"Redirecting to case-insensitive match" "Redirecting to case-insensitive match"
Nothing -> case findPage prefixMatch of Nothing -> seeOther (base' ++ urlForPage gotopage) $ toResponse
Just m -> seeOther (base' ++ urlForPage m) $ "Redirecting to new page"
toResponse $ "Redirecting" ++
" to partial match"
Nothing -> searchResults


searchResults :: Handler searchResults :: Handler
searchResults = withData $ \(params :: Params) -> do searchResults = withData $ \(params :: Params) -> do
Expand Down

0 comments on commit 1328545

Please sign in to comment.