importfeed: Filename template can now contain an itempubdate variable. Needs feed 0.3.9.2.
This commit is contained in:
parent
5b503e4458
commit
836f2cc816
7 changed files with 24 additions and 4 deletions
|
@ -15,6 +15,8 @@ import Text.Feed.Types
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
|
import Data.Time.Format
|
||||||
|
import System.Locale
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
@ -212,6 +214,7 @@ feedFile tmpl i extension = Utility.Format.format tmpl $ M.fromList
|
||||||
, fieldMaybe "itemdescription" $ getItemDescription $ item i
|
, fieldMaybe "itemdescription" $ getItemDescription $ item i
|
||||||
, fieldMaybe "itemrights" $ getItemRights $ item i
|
, fieldMaybe "itemrights" $ getItemRights $ item i
|
||||||
, fieldMaybe "itemid" $ snd <$> getItemId (item i)
|
, fieldMaybe "itemid" $ snd <$> getItemId (item i)
|
||||||
|
, fieldMaybe "itempubdate" $ pubdate $ item i
|
||||||
, ("extension", sanitizeFilePath extension)
|
, ("extension", sanitizeFilePath extension)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
@ -221,6 +224,12 @@ feedFile tmpl i extension = Utility.Format.format tmpl $ M.fromList
|
||||||
fieldMaybe k Nothing = (k, "none")
|
fieldMaybe k Nothing = (k, "none")
|
||||||
fieldMaybe k (Just v) = field k v
|
fieldMaybe k (Just v) = field k v
|
||||||
|
|
||||||
|
pubdate itm = case getItemPublishDate itm :: Maybe (Maybe UTCTime) of
|
||||||
|
Just (Just d) -> Just $
|
||||||
|
formatTime defaultTimeLocale "%F" d
|
||||||
|
-- if date cannot be parsed, use the raw string
|
||||||
|
_ -> replace "/" "-" <$> getItemPublishDateString itm
|
||||||
|
|
||||||
{- Called when there is a problem with a feed.
|
{- Called when there is a problem with a feed.
|
||||||
- Throws an error if the feed is broken, otherwise shows a warning. -}
|
- Throws an error if the feed is broken, otherwise shows a warning. -}
|
||||||
feedProblem :: URLString -> String -> Annex ()
|
feedProblem :: URLString -> String -> Annex ()
|
||||||
|
|
7
debian/changelog
vendored
7
debian/changelog
vendored
|
@ -1,3 +1,10 @@
|
||||||
|
git-annex (5.20140406) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* importfeed: Filename template can now contain an itempubdate variable.
|
||||||
|
Needs feed 0.3.9.2.
|
||||||
|
|
||||||
|
-- Joey Hess <joeyh@debian.org> Mon, 07 Apr 2014 16:22:02 -0400
|
||||||
|
|
||||||
git-annex (5.20140405) unstable; urgency=medium
|
git-annex (5.20140405) unstable; urgency=medium
|
||||||
|
|
||||||
* git-annex-shell: Added notifychanges command.
|
* git-annex-shell: Added notifychanges command.
|
||||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -55,7 +55,7 @@ Build-Depends:
|
||||||
libghc-xml-types-dev,
|
libghc-xml-types-dev,
|
||||||
libghc-async-dev,
|
libghc-async-dev,
|
||||||
libghc-http-dev,
|
libghc-http-dev,
|
||||||
libghc-feed-dev,
|
libghc-feed-dev (>= 0.3.9.2),
|
||||||
libghc-regex-tdfa-dev [!mipsel !s390],
|
libghc-regex-tdfa-dev [!mipsel !s390],
|
||||||
libghc-regex-compat-dev [mipsel s390],
|
libghc-regex-compat-dev [mipsel s390],
|
||||||
libghc-tasty-dev (>= 0.7) [!mipsel !sparc],
|
libghc-tasty-dev (>= 0.7) [!mipsel !sparc],
|
||||||
|
|
|
@ -268,7 +268,7 @@ subdirectories).
|
||||||
|
|
||||||
Use `--template` to control where the files are stored.
|
Use `--template` to control where the files are stored.
|
||||||
The default template is '${feedtitle}/${itemtitle}${extension}'
|
The default template is '${feedtitle}/${itemtitle}${extension}'
|
||||||
(Other available variables: feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid)
|
(Other available variables: feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid, itempubdate)
|
||||||
|
|
||||||
The `--relaxed` and `--fast` options behave the same as they do in addurl.
|
The `--relaxed` and `--fast` options behave the same as they do in addurl.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ there's a --template option. The default is
|
||||||
`--template='${feedtitle}/${itemtitle}${extension}'`
|
`--template='${feedtitle}/${itemtitle}${extension}'`
|
||||||
|
|
||||||
Other available template variables:
|
Other available template variables:
|
||||||
feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid
|
feedauthor, itemauthor, itemsummary, itemdescription, itemrights, itemid,
|
||||||
|
itempubdate
|
||||||
|
|
||||||
## catching up
|
## catching up
|
||||||
|
|
||||||
|
|
|
@ -13,3 +13,6 @@ or
|
||||||
that "works" but is ugly :)
|
that "works" but is ugly :)
|
||||||
|
|
||||||
Would love to be able to put a YYYYMMDD at the beginning and then the title.
|
Would love to be able to put a YYYYMMDD at the beginning and then the title.
|
||||||
|
|
||||||
|
> [[done]]; itempubdate will use form YYYY-MM-DD (or the raw date string
|
||||||
|
> if the feed does not use a parsable form). --[[Joey]]
|
||||||
|
|
|
@ -210,7 +210,7 @@ Executable git-annex
|
||||||
CPP-Options: -DWITH_DNS
|
CPP-Options: -DWITH_DNS
|
||||||
|
|
||||||
if flag(Feed)
|
if flag(Feed)
|
||||||
Build-Depends: feed
|
Build-Depends: feed (>= 0.3.9.2)
|
||||||
CPP-Options: -DWITH_FEED
|
CPP-Options: -DWITH_FEED
|
||||||
|
|
||||||
if flag(Quvi)
|
if flag(Quvi)
|
||||||
|
|
Loading…
Reference in a new issue