diff options
author | Joey Hess <joey@kitenet.net> | 2013-07-28 19:08:50 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-07-28 19:08:50 -0400 |
commit | 1d1ad341a161ca352d967fa64449f23335fecf54 (patch) | |
tree | 4697822d7fe4849073d892a8cbcb66ae653b9be0 /Command | |
parent | 2d822b53dd312ce14edbba8d4e7e3cb106dfb842 (diff) |
better extension handling
When there's no extension, don't use "none", but "".
When there is an extension, it starts with a dot, so don't put a redundant
dot in the default format.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/ImportFeed.hs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index 2a263c5e3..682a7faa1 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -23,17 +23,6 @@ import qualified Utility.Format import Utility.Tmp import Command.AddUrl (addUrlFile, relaxedOption) -data ToDownload = ToDownload - { feed :: Feed - , item :: Item - , location :: URLString - } - -mkToDownload :: Feed -> Item -> Maybe ToDownload -mkToDownload f i = case getItemEnclosure i of - Nothing -> Nothing - Just (enclosureurl, _, _) -> Just $ ToDownload f i enclosureurl - def :: [Command] def = [notBareRepo $ withOptions [templateOption, relaxedOption] $ command "importfeed" (paramRepeating paramUrl) seek @@ -62,6 +51,17 @@ perform relaxed cache url = do next $ return True _ -> stop +data ToDownload = ToDownload + { feed :: Feed + , item :: Item + , location :: URLString + } + +mkToDownload :: Feed -> Item -> Maybe ToDownload +mkToDownload f i = case getItemEnclosure i of + Nothing -> Nothing + Just (enclosureurl, _, _) -> Just $ ToDownload f i enclosureurl + data Cache = Cache { knownurls :: S.Set URLString , template :: Utility.Format.Format @@ -111,7 +111,7 @@ downloadEnclosure relaxed cache enclosure url = location enclosure defaultTemplate :: String -defaultTemplate = "${feedtitle}/${itemtitle}.${extension}" +defaultTemplate = "${feedtitle}/${itemtitle}${extension}" {- Generate a unique filename for the feed item by filling - out the template. @@ -131,7 +131,7 @@ feedFile tmpl i = makeUnique 0 $ , fieldMaybe "itemdescription" $ getItemDescription $ item i , fieldMaybe "itemrights" $ getItemRights $ item i , fieldMaybe "itemid" $ snd <$> getItemId (item i) - , field "extension" $ takeExtension $ location i + , ("extension", map sanitize $ takeExtension $ location i) ] where field k v = |