| author | plurSKI <black.gavin@gmail.com> | 2010-10-24 16:58:21 (GMT) |
|---|---|---|
| committer | plurSKI <black.gavin@gmail.com> | 2010-10-24 16:58:21 (GMT) |
| commit | ea136d4db71911193c5271c61f0dcdd8baa521b9 (patch) | |
| tree | 4f2a619dafca697078429f4c68dba5b4bca3f238 | |
| parent | 54f9a9184b32a7d9446bde045ad2e3eade39c01b (diff) | |
| download | haskellSite-master.zip haskellSite-master.tar.gz | |
Fixed random distribution and list navigationmaster
| -rw-r--r-- | src/DataStore.hs | 2 | ||||
| -rw-r--r-- | src/Glue.hs | 4 | ||||
| -rw-r--r-- | src/Splices.hs | 6 | ||||
| -rw-r--r-- | static/js/ready.js | 4 | ||||
| -rw-r--r-- | templates/common/list-content.tpl | 2 | ||||
| -rw-r--r-- | templates/devrand/page-navigationB.tpl | 6 |
6 files changed, 16 insertions, 8 deletions
diff --git a/src/DataStore.hs b/src/DataStore.hs index 8e10cf2..cf0c23a 100644 --- a/src/DataStore.hs +++ b/src/DataStore.hs @@ -131,7 +131,7 @@ getImageScrolls s num = do file <- safeRead ("/siteData/admin/" ++ s ++ "/ImageScrolls.dat") let list = Prelude.read file :: [ImageScroll] gen <- newStdGen - let rVals = randomRs (0, (length list) - 1) gen + let rVals = nub $ randomRs (0, (length list) - 1) gen let pics = take num rVals return $ map (\x -> list !! x) pics diff --git a/src/Glue.hs b/src/Glue.hs index 5628163..5ac54cd 100644 --- a/src/Glue.hs +++ b/src/Glue.hs @@ -54,12 +54,14 @@ renderList ts count sort tag = do bytes <- renderTemplate ts $ B.concat [mapName' host, "/list"] indiv <- renderTemplate ts $ B.concat [mapName' host, "/list-table"] list <- liftIO $ makeListItems (B.unpack (fromJust indiv)) (B.unpack host) (tag', sort, count) - selForward <- liftIO $ makeSelForward (B.unpack host) (tag', sort, count) + selForward <- liftIO $ makeSelForward 0 (B.unpack host) (tag', sort, count) + selForwardB <- liftIO $ makeSelForward 1 (B.unpack host) (tag', sort, count) flip (maybe pass) (bytes) $ \x -> do let finalOutput = foldl (\x (y,z) -> replaceAll x y z) (B.unpack x) [ ("$$LIST$$", list) , ("$$TAGNAME$$", tag') , ("$$BACKLINK$$", makeBackLink tag' sort count ) , ("$$SELECTFORWARD$$", selForward ) + , ("$$SELECTFORWARDB$$", selForwardB ) , ("$$TITLE$$", B.unpack host ++ ": " ++ tag' ++ " Posts" ) ] modifyResponse $ setContentType "text/html; charset=utf-8" diff --git a/src/Splices.hs b/src/Splices.hs index 305895d..e4c50a7 100644 --- a/src/Splices.hs +++ b/src/Splices.hs @@ -22,13 +22,13 @@ makeBackLink :: String -> SortType -> Int -> String makeBackLink _ _ 0 = "<Prev" makeBackLink tag sort count = concat ["<a href=\"/list/", tag, "/", show sort, "/", show (count - 1), "\"><Prev</a>"] -makeSelForward :: String -> (String, SortType, Int) -> IO String -makeSelForward host (tag, sort, count) = do +makeSelForward :: Int -> String -> (String, SortType, Int) -> IO String +makeSelForward n host (tag, sort, count) = do let len = maxList * (count + 1) postList <- getPosts host sort tag 1000 -- kludge to get all matching posts let numPages = ((length postList) - 1) `div` maxList let selectOptions = concat $ makeSelect numPages - return $ concat ["<select id=\"pageSel\" onChange=\"pageNav();\">\n", selectOptions, "</select> | \n", makeForward numPages] + return $ concat ["<select id=\"pageSel", show n, "\" onChange=\"pageNav(", show n ,");\">\n", selectOptions, "</select> | \n", makeForward numPages] where makeSelect numPages = Data.List.map makeOption [0..numPages] makeForward numPages | count < numPages = "<a href=\"" ++ makeUrl (count + 1) ++ "\">Next ></a>" | otherwise = "Next >" diff --git a/static/js/ready.js b/static/js/ready.js index 075d93a..d3e0baa 100644 --- a/static/js/ready.js +++ b/static/js/ready.js @@ -66,8 +66,8 @@ function commentExpand() $("#unHREF").html("- Add a comment"); } -function pageNav() +function pageNav( x ) { - var newUrl = $("#pageSel").val(); + var newUrl = $("#pageSel" + x).val(); window.location = newUrl; } diff --git a/templates/common/list-content.tpl b/templates/common/list-content.tpl index ec6d646..36459a8 100644 --- a/templates/common/list-content.tpl +++ b/templates/common/list-content.tpl @@ -10,6 +10,6 @@ </table> <HR /> <div id="pageNavigationBot"> - <apply template="page-navigation" /> + <apply template="page-navigationB" /> </div> </div> diff --git a/templates/devrand/page-navigationB.tpl b/templates/devrand/page-navigationB.tpl new file mode 100644 index 0000000..45c177c --- a/dev/null +++ b/templates/devrand/page-navigationB.tpl @@ -0,0 +1,6 @@ + <span class="sectionName">$$TAGNAME$$ Posts</span> + <span class="sectionNav"> + $$BACKLINK$$ + | Page: $$SELECTFORWARDB$$ + </span> + |
