[take hyphens out of template names thomashartman1@gmail.com**20080920121648] move ./templates/accountsettings-changed.st ./templates/accountsettingschanged.st move ./templates/basic-url-handling.st ./templates/basicurlhandling.st move ./templates/happs-slow-linking-bug.st ./templates/happsslowlinkingbug.st move ./templates/main-function.st ./templates/mainfunction.st move ./templates/run-tutorial-locally.st ./templates/runtutoriallocally.st move ./templates/start-happs-on-boot.st ./templates/starthappsonboot.st move ./templates/stringtemplate-basics.st ./templates/stringtemplatebasics.st move ./templates/templates-dont-repeat-yourself.st ./templates/templatesdontrepeatyourself.st move ./templates/understanding-happs-types.st ./templates/understandinghappstypes.st hunk ./src/Controller.hs 59 - lastPathPartSp0 (\rq tmpl -> ( return . tutlayoutU rglobs []) tmpl ) + lastPathPartSp0 (\rq tmpl -> ( return . tutlayoutU rglobs [] . cleanPunctuation) tmpl ) hunk ./src/Controller.hs 70 +cleanPunctuation tmpl = filter (/= '-') tmpl + hunk ./src/Misc.hs 13 +import Control.Applicative +import System.Directory +import System.FilePath hunk ./src/Misc.hs 119 + +-- HStringTemplate modifications -- copy/paste/tweak from HStringTemplate. +-- same as directoryGroup, but throws an error for template names with punctuation + +saferDirectoryGroup :: (Stringable a) => FilePath -> IO (STGroup a) +saferDirectoryGroup path = groupStringTemplates <$> + (fmap <$> zip . (map dropExtension) + <*> mapM (newSTMP <$$> (readFile . (path >))) + =<< return . filter ( (".st" ==) . takeExtension ) + =<< mapM checkTmplName =<< getDirectoryContents path) + + + +checkTmplName t = if isInfixOf "-" t || isInfixOf "_" t + then fail $ "safeDirectoryGroup, bad template name: " ++ t + else return t + +(<$$>) :: (Functor f1, Functor f) => (a -> b) -> f (f1 a) -> f (f1 b) +(<$$>) x y = ((<$>) . (<$>)) x y + hunk ./src/View.hs 34 -getTemplates = directoryGroup "templates" +getTemplates = saferDirectoryGroup "templates" hunk ./templates/templatesdontrepeatyourself.st 22 -
Have a look at the template responsible for the content pane of this page. It's pretty boring, except the line above reads as +
Have a look at the template responsible for the content pane of this page. It's pretty boring, except the line above reads as