By | Chris Done |
At | 2013-07-20 |
Title | Add RSS feed for channels. |
Description |
Edit file hpaste.cabal 33188 → 33188
100 100 ,blaze-markup >= 0.5
101 101 -- Soft versions
102 102 ,base >= 4 && < 5
103 103 ,css >= 0.1
104 104 ,named-formlet >= 0.2
- 105 ,snap-app >= 0.4.0
+ 105 ,snap-app >= 0.6.0
106 106 -- Free versions
107 107 ,ConfigFile
108 108 ,HJScript
109 109 ,MissingH
110 110 ,MonadCatchIO-transformers
… … … … Edit file src/Main.hs 33188 → 33188
14 14 import Hpaste.Controller.Paste as Paste
15 15 import Hpaste.Controller.Raw as Raw
16 16 import Hpaste.Controller.Report as Report
17 17 import Hpaste.Controller.Reported as Reported
18 18 import Hpaste.Controller.Style as Style
+ 19 import Hpaste.Controller.Rss as Rss
19 20 import Hpaste.Controller.Script as Script
20 21 import Hpaste.Model.Announcer (newAnnouncer)
21 22 import Hpaste.Types
22 23 import Hpaste.Types.Announcer
23 24 … … … … 61 62 ,("/new/:channel",run (New.handle New.NewPaste))
62 63 ,("/browse",run Browse.handle)
63 64 ,("/activity",run Activity.handle)
64 65 ,("/diff/:this/:that",run Diff.handle)
65 66 ,("/delete",run Report.handleDelete)
+ 67 ,("/channel/:channel/rss",run Rss.handle)
66 68 ]
67 69 run = runHandler ans config pool
… … … … Edit file src/Hpaste/Model/Paste.hs 33188 → 33188
58 58 ,"WHERE (? IS NULL) OR (author = ?) AND spamrating < ?"]
59 59 (mauthor,mauthor,spamMinLevel)
60 60 return $ fromMaybe 0 rows
61 61 62 62 -- | Get the latest pastes.
- 63 getLatestPastes :: HPModel [Paste]
- 64 getLatestPastes =
+ 63 getLatestPastes :: Maybe ChannelId -> HPModel [Paste]
+ 64 getLatestPastes channel =
65 65 query ["SELECT ",pasteFields
66 66 ,"FROM public_toplevel_paste"
67 67 ,"WHERE spamrating < ?"
+ 68 ,"AND channel = ?"
68 69 ,"ORDER BY created DESC"
69 70 ,"LIMIT 20"]
- 70 (Only spamMinLevel)
+ 71 (spamMinLevel,channel)
71 72 72 73 -- | Get some paginated pastes.
73 74 getPaginatedPastes :: Maybe String -> Pagination -> HPModel (Pagination,[Paste])
74 75 getPaginatedPastes mauthor pn@Pagination{..} = do
75 76 total <- countPublicPastes mauthor
… … … … Edit file src/Hpaste/Controller/Home.hs 33188 → 33188
21 21 22 22 -- | Handle the home page, display a simple list and paste form.
23 23 handle :: Bool -> HPCtrl ()
24 24 handle spam = do
25 25 html <- cacheIf (not spam) Key.Home $ do
- 26 pastes <- model $ getLatestPastes
+ 26 pastes <- model $ getLatestPastes Nothing
27 27 chans <- model $ getChannels
28 28 langs <- model $ getLanguages
29 29 form <- pasteForm chans langs Nothing Nothing Nothing
30 30 uri <- getMyURI
31 31 return $ Just $ page uri chans langs pastes form spam
… … … …