manatee-reader 0.0.6 → 0.0.7
raw patch · 10 files changed
+241/−49 lines, 10 filesdep +filepathdep ~manatee-coresetup-changed
Dependencies added: filepath
Dependency ranges changed: manatee-core
Files
- Config/Default.hs +47/−0
- Config/Import.hs +21/−0
- Config/Reader.hs +47/−0
- Config/User.hs +19/−0
- Main.hs +6/−2
- Manatee/Extension/Reader/ReaderBuffer.hs +16/−42
- Manatee/Extension/Reader/ReaderView.hs +4/−0
- Manatee/Extension/Reader/Types.hs +57/−0
- Setup.hs +8/−1
- manatee-reader.cabal +16/−4
+ Config/Default.hs view
@@ -0,0 +1,47 @@+-- Author: Andy Stewart <lazycat.manatee@gmail.com>+-- Maintainer: Andy Stewart <lazycat.manatee@gmail.com>+-- +-- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- +-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- any later version.+-- +-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+-- +-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++module Config.Default where++import Manatee.Extension.Reader.Types++import qualified Data.Map as M++-- | Temp feed information, instead with user customize option after customize system complete. +feedInfos :: FeedDB+feedInfos = + M.fromList [("Planet Haskell"+ ,FeedInfo "http://planet.haskell.org/rss20.xml" + [Minute 30])+ ,("HackageDB recent additions"+ ,FeedInfo "http://hackage.haskell.org/packages/archive/recent.rss"+ [Minute 20])+ ,("Planet Emacsen"+ ,FeedInfo "http://planet.emacsen.org/atom.xml"+ [Minute 20])+ ,("Aqee.net"+ ,FeedInfo "http://feed.feedsky.com/aqee-net"+ [Minute 30]+ )+ ,("Yeeyan-Science"+ ,FeedInfo "http://feed.feedsky.com/yeeyan-science"+ [Minute 20])+ ,("Yeeyan-Tech"+ ,FeedInfo "http://feed.feedsky.com/yeeyan-tech"+ [Minute 20])+ ]
+ Config/Import.hs view
@@ -0,0 +1,21 @@+-- Author: Andy Stewart <lazycat.manatee@gmail.com>+-- Maintainer: Andy Stewart <lazycat.manatee@gmail.com>+-- +-- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- +-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- any later version.+-- +-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+-- +-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++module Config.Import (feedInfos) where ++import Config.Default
+ Config/Reader.hs view
@@ -0,0 +1,47 @@+-- Author: Andy Stewart <lazycat.manatee@gmail.com>+-- Maintainer: Andy Stewart <lazycat.manatee@gmail.com>+-- +-- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- +-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- any later version.+-- +-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+-- +-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++module Config.User where++import Manatee.Extension.Reader.Types++import qualified Data.Map as M++-- | Temp feed information, instead with user customize option after customize system complete. +feedInfos :: FeedDB+feedInfos = + M.fromList [("Planet Haskell"+ ,FeedInfo "http://planet.haskell.org/rss20.xml" + [Minute 30])+ ,("HackageDB recent additions"+ ,FeedInfo "http://hackage.haskell.org/packages/archive/recent.rss"+ [Minute 20])+ ,("Planet Emacsen"+ ,FeedInfo "http://planet.emacsen.org/atom.xml"+ [Minute 20])+ ,("Aqee.net"+ ,FeedInfo "http://feed.feedsky.com/aqee-net"+ [Minute 30]+ )+ ,("Yeeyan-Science"+ ,FeedInfo "http://feed.feedsky.com/yeeyan-science"+ [Minute 20])+ ,("Yeeyan-Tech"+ ,FeedInfo "http://feed.feedsky.com/yeeyan-tech"+ [Minute 20])+ ]
+ Config/User.hs view
@@ -0,0 +1,19 @@+-- Author: Andy Stewart <lazycat.manatee@gmail.com>+-- Maintainer: Andy Stewart <lazycat.manatee@gmail.com>+-- +-- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- +-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- any later version.+-- +-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+-- +-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++module Config.User where
Main.hs view
@@ -21,12 +21,16 @@ module Main where import Control.Applicative hiding (empty)+import Manatee.Core.Dynload import Manatee.Core.Render import Manatee.Core.Types import Manatee.Extension.Reader+import Manatee.Extension.Reader.Types -- | Irc client render process. main :: IO () main = - startupRender (\ pagePath options client pageId -> - PageBufferWrap <$> readerBufferNew pagePath options client pageId)+ startupRender + (\ pagePath options client pageId customize -> + PageBufferWrap <$> readerBufferNew pagePath options client pageId customize)+ readerCustomizeNew
Manatee/Extension/Reader/ReaderBuffer.hs view
@@ -20,6 +20,7 @@ {-# LANGUAGE DeriveDataTypeable #-} module Manatee.Extension.Reader.ReaderBuffer where +import Config.Import import Codec.Binary.UTF8.String import Control.Applicative import Control.Concurrent@@ -32,8 +33,10 @@ import Data.Typeable import Graphics.UI.Gtk.General.General import Graphics.UI.Gtk.ModelView.TreeSortable+import Manatee.Core.Dynload import Manatee.Core.Types import Manatee.Extension.Reader.PageMode+import Manatee.Extension.Reader.Types import Manatee.Toolkit.General.List import Manatee.Toolkit.General.Map import Manatee.Toolkit.General.Maybe@@ -55,22 +58,13 @@ ,readerBufferFeedNavItems :: TVar (Map FeedName [FeedNavItem]) ,readerBufferFeedNavOptions :: [(NavItemOption, SortColumnId)] ,readerBufferBroadcastChannel :: TChan ReaderTChanSignal+ ,readerBufferCustomize :: ReaderCustomize } deriving Typeable data ReaderTChanSignal = FeedUpdated FeedName deriving (Show, Eq, Ord) -data Interval = Second Int- | Minute Int- | Hour Int- | Day Int- deriving (Show, Eq, Ord)--type FetchNumber = Int-type FeedUrl = String-type FeedName = String- data FeedTreeItem = FeedTreeItem {ftiName :: String ,ftiUnreadNumber :: Int@@ -128,15 +122,12 @@ niCompareRow NTitle item1 item2 = return $ comparing fniTitle item1 item2 niCompareRow NTime item1 item2 = return $ comparing fniTime item1 item2 -data FeedInfo =- FeedInfo {feedUrl :: FeedUrl -- feed url- ,feedInterval :: [Interval] -- interval time between retrievals- }- deriving Show- -- | Create reader buffer.-readerBufferNew :: String -> [String] -> Client -> PageId -> IO ReaderBuffer-readerBufferNew path _ client pageId = do+readerBufferNew :: String -> [String] -> Client -> PageId -> CustomizeWrap -> IO ReaderBuffer+readerBufferNew path _ client pageId c = do+ let customize = castCustomize c+ feedInfos <- readTVarIO (readerCustomizeFeedInfos customize)+ buffer <- ReaderBuffer <$> pure path <*> pure client <*> pure pageId@@ -147,6 +138,7 @@ <*> newTVarIO M.empty <*> pure (pairPred [NTitle, NTime]) <*> (newTChanIO :: IO (TChan ReaderTChanSignal))+ <*> pure customize -- Fetch feed. readerBufferFetchFeed buffer@@ -161,7 +153,7 @@ -- | Update feed. readerBufferUpdateFeed :: ReaderBuffer -> FeedName -> IO ()-readerBufferUpdateFeed buffer@(ReaderBuffer {readerBufferFeedInfos = infos} )+readerBufferUpdateFeed buffer@(ReaderBuffer {readerBufferFeedInfos = infos}) feedName = do forkIO $ findMinMatch infos (\ name _ -> name == feedName) @@ -214,27 +206,9 @@ Hour t -> t * 60 * 60 Day t -> t * 60 * 60 * 24 --- | Temp feed information, instead with user customize option after customize system complete. -feedInfos :: Map FeedName FeedInfo -feedInfos = - M.fromList [("Planet Haskell"- ,FeedInfo "http://planet.haskell.org/rss20.xml" - [Minute 30])- ,("HackageDB recent additions"- ,FeedInfo "http://hackage.haskell.org/packages/archive/recent.rss"- [Minute 20])- ,("Planet Emacsen"- ,FeedInfo "http://planet.emacsen.org/atom.xml"- [Minute 20])- ,("Yeeyan-Science"- ,FeedInfo "http://feed.feedsky.com/yeeyan-science"- [Minute 20])- ,("Yeeyan-Tech"- ,FeedInfo "http://feed.feedsky.com/yeeyan-tech"- [Minute 20])- -- ,("Google Arcanum"- -- ,FeedInfo "http://rss.guao.cc/aggregator/rss"- -- [Minute 20])- ]-+-- | Reader customize new.+readerCustomizeNew :: IO CustomizeWrap+readerCustomizeNew =+ fmap CustomizeWrap+ ReaderCustomize <$> newTVarIO feedInfos
Manatee/Extension/Reader/ReaderView.hs view
@@ -34,12 +34,15 @@ import Manatee.Core.PageView import Manatee.Core.Types import Manatee.Extension.Reader.ReaderBuffer+import Manatee.Extension.Reader.Types import Manatee.Toolkit.General.Map import Manatee.Toolkit.General.Maybe import Manatee.Toolkit.Gtk.Concurrent import Manatee.Toolkit.Gtk.Gtk import Manatee.Toolkit.Gtk.ModelView import Manatee.Toolkit.Gtk.ScrolledWindow+import Paths_manatee_reader+import System.FilePath import qualified Data.Map as M @@ -72,6 +75,7 @@ pageBufferClient = readerBufferClient pageBufferCreateView a pId = PageViewWrap <$> readerViewNew a pId pageBufferMode = readerBufferMode+ pageBufferPackageName _ = fmap takeFileName getDataDir instance PageView ReaderView where pageViewBuffer = PageBufferWrap . readerViewBuffer
+ Manatee/Extension/Reader/Types.hs view
@@ -0,0 +1,57 @@+-- Author: Andy Stewart <lazycat.manatee@gmail.com>+-- Maintainer: Andy Stewart <lazycat.manatee@gmail.com>+-- +-- Copyright (C) 2010 Andy Stewart, all rights reserved.+-- +-- This program is free software: you can redistribute it and/or modify+-- it under the terms of the GNU General Public License as published by+-- the Free Software Foundation, either version 3 of the License, or+-- any later version.+-- +-- This program is distributed in the hope that it will be useful,+-- but WITHOUT ANY WARRANTY; without even the implied warranty of+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+-- GNU General Public License for more details.+-- +-- You should have received a copy of the GNU General Public License+-- along with this program. If not, see <http://www.gnu.org/licenses/>.++{-# LANGUAGE DeriveDataTypeable #-}+module Manatee.Extension.Reader.Types where++import Control.Concurrent.STM +import Data.Map (Map)+import Data.Typeable+import Manatee.Core.Types+import Manatee.Toolkit.General.STM+import Unsafe.Coerce++data ReaderCustomize = + ReaderCustomize {readerCustomizeFeedInfos :: TVar FeedDB+ }+ deriving Typeable++instance Customize ReaderCustomize where + customizeConfigFile _ = "Reader.hs"+ customizeLoad a =+ [("feedInfos"+ ,\v -> writeTVarIO (readerCustomizeFeedInfos a) (unsafeCoerce v :: FeedDB))]++type FeedDB = Map FeedName FeedInfo++data Interval = Second Int+ | Minute Int+ | Hour Int+ | Day Int+ deriving (Show, Eq, Ord)++type FetchNumber = Int+type FeedUrl = String+type FeedName = String++data FeedInfo =+ FeedInfo {feedUrl :: FeedUrl -- feed url+ ,feedInterval :: [Interval] -- interval time between retrievals+ }+ deriving Show+
Setup.hs view
@@ -16,8 +16,10 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. +import Distribution.PackageDescription import Distribution.Simple import Manatee.Core.Config+import Manatee.Core.Dynload import Manatee.Core.Types import Manatee.Extension.Reader.PageMode @@ -25,8 +27,13 @@ main = defaultMainWithHooks simpleUserHooks {+ -- Generate User.hs and Import.hs before configure.+ preConf = \ _ _ -> do+ generateConfig "Reader.hs"+ ["feedInfos"]+ return emptyHookedBuildInfo -- Update PageTypeRule after install successful.- postInst = \ _ _ _ _ -> do+ ,postInst = \ _ _ _ _ -> do (PageTypeRule rule) <- readConfig pageTypeRulePath (PageTypeRule M.empty) writeConfig pageTypeRulePath (PageTypeRule (M.insert "PageReader" "manatee-reader" rule)) -- Update PageModeRule.
manatee-reader.cabal view
@@ -1,5 +1,5 @@ name: manatee-reader-version: 0.0.6+version: 0.0.7 Cabal-Version: >= 1.6 license: GPL-3 license-file: LICENSE@@ -7,8 +7,12 @@ synopsis: Feed reader extension for Manatee. description: manatee-reader is feed reader extension for Manatee (Haskell/Gtk+ Integrated Live Environment) .- Video at (Select 720p HD) at : <http://www.youtube.com/watch?v=weS6zys3U8k> <http://v.youku.com/v_show/id_XMjI2MDMzODI4.html>+ Default configuration template at Config\/Reader.hs, copy to directory `HOME/.manatee/config/`. .+ Note, you need re-install package to start the configuration file take effect the next time,+ .+ Video at (Select 720p HD) at : <http://www.youtube.com/watch?v=weS6zys3U8k> <http://www.youtube.com/watch?v=A3DgKDVkyeM> <http://v.youku.com/v_show/id_XMjI2MDMzODI4.html>+ . Screenshots at : <http://goo.gl/MkVw> . Manual at : <http://haskell.org/haskellwiki/Manatee>@@ -25,21 +29,29 @@ tested-with: GHC==6.12.3 build-type: Custom +data-dir: ""+data-files: Config/Reader.hs + Source-Repository head type: darcs location: http://patch-tag.com/r/AndyStewart/manatee-reader Library- build-depends: base >= 4 && < 5, manatee-core >= 0.0.6, dbus-client >= 0.3 && < 0.4, stm >= 2.1.2.0,+ build-depends: base >= 4 && < 5, manatee-core >= 0.0.7, dbus-client >= 0.3 && < 0.4, stm >= 2.1.2.0, containers >= 0.3.0.0, gtk-serialized-event >= 0.12.0, gtk >= 0.12.0, text >= 0.7.1.0, webkit >= 0.12.0, feed >= 0.3.7, download-curl >= 0.1.2,- utf8-string >= 0.3.4+ utf8-string >= 0.3.4, filepath exposed-modules: Manatee.Extension.Reader Manatee.Extension.Reader.ReaderBuffer Manatee.Extension.Reader.ReaderView Manatee.Extension.Reader.PageMode+ Manatee.Extension.Reader.Types other-modules: + Paths_manatee_reader+ Config.Default+ Config.User+ Config.Import extensions: ghc-options: -fwarn-unused-matches -fwarn-unused-binds -fwarn-unused-imports -fwarn-overlapping-patterns -fwarn-duplicate-exports -fwarn-unrecognised-pragmas -fwarn-hi-shadowing