panda 2008.12.16 → 2009.1.20
raw patch · 4 files changed
+110/−30 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- panda.cabal +26/−25
- src/Panda/Model/Video.hs +44/−0
- src/Panda/Type/Plugin.hs +10/−5
- src/Panda/View/Atom/Video.hs +30/−0
panda.cabal view
@@ -1,5 +1,5 @@ Name: panda-Version: 2008.12.16+Version: 2009.1.20 Build-type: Simple Synopsis: A simple static blog engine Description: A simple static blog engine@@ -24,52 +24,53 @@ Panda.Controller.Application - Panda.Helper.Env Panda.Helper.Helper+ Panda.Helper.StateHelper Panda.Helper.Html+ Panda.Helper.Env Panda.Helper.PreludeEnv- Panda.Helper.StateHelper Panda.Helper.ThumbHelper - Panda.Model.Album- Panda.Model.Comment- Panda.Model.Helper+ Panda.Model.Tag Panda.Model.Post+ Panda.Model.Helper+ Panda.Model.Video+ Panda.Model.Comment+ Panda.Model.Album Panda.Model.Static- Panda.Model.Tag - Panda.Type.Extension- Panda.Type.Pager- Panda.Type.Reader+ Panda.Type.Theme Panda.Type.Plugin+ Panda.Type.Pager Panda.Type.State Panda.Type.StaticWidget- Panda.Type.Theme-+ Panda.Type.Reader+ Panda.Type.Extension - Panda.View.Atom.Album- Panda.View.Atom.Comment+ Panda.View.Atom.Tag Panda.View.Atom.Post+ Panda.View.Atom.Video+ Panda.View.Atom.Comment+ Panda.View.Atom.Album Panda.View.Atom.Static- Panda.View.Atom.Tag - Panda.View.Control.Comment- Panda.View.Control.Helper+ Panda.View.Control.Tag Panda.View.Control.Post+ Panda.View.Control.Helper+ Panda.View.Control.Comment Panda.View.Control.Search Panda.View.Control.Static- Panda.View.Control.Tag - Panda.View.Widget.Body- Panda.View.Widget.Footer- Panda.View.Widget.Head- Panda.View.Widget.Header+ Panda.View.Widget.Template Panda.View.Widget.Helper+ Panda.View.Widget.Header+ Panda.View.Widget.Sidebar Panda.View.Widget.Navigation- Panda.View.Widget.RSS Panda.View.Widget.SearchBar- Panda.View.Widget.Sidebar- Panda.View.Widget.Template+ Panda.View.Widget.Head+ Panda.View.Widget.RSS+ Panda.View.Widget.Body+ Panda.View.Widget.Footer
+ src/Panda/Model/Video.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE NoImplicitPrelude #-}++module Panda.Model.Video where++-- env+import Panda.Helper.Env hiding (title, body, size, path, meta, get, width, height)+import qualified Panda.Config.Global as G+import Panda.Helper.StateHelper++data VideoType = MediaPlayer deriving (Eq, Show, Read)++instance Default VideoType where+ def = MediaPlayer ++data Video = Video+ { uid :: String -- album/08-06-10+ , preview :: String+ , width :: Int+ , height :: Int+ , video_type :: VideoType+ }+ deriving (Show, Eq)++instance Resource Video where+ resource_title = uid > spaced_url+ +data VideoData = + Link+ | Preview+ | Width+ | Height+ | Type+ deriving (Show)++from_list xs = Video + { uid = at Link+ , preview = at' Preview ""+ , width = at' Width "400" .read+ , height = at' Height "300" .read+ , video_type = at' Type "media_player" .camel_case.read+ } .return + where+ at x = xs.lookup (x.show_data).fromJust+ at' x d = xs.lookup (x .show_data) .fromMaybe d
src/Panda/Type/Plugin.hs view
@@ -3,9 +3,11 @@ import Panda.Helper.Env hiding (body, name) import qualified Panda.Model.Album as Album+import qualified Panda.Model.Video as V import qualified Panda.View.Atom.Album as AlbumV+import qualified Panda.View.Atom.Video as VV -data PluginType = PhotoAlbum | None deriving (Show, Eq)+data PluginType = PhotoAlbum | Video | None deriving (Show, Eq) data Plugin = Plugin { plugin_type :: PluginType@@ -21,7 +23,7 @@ -- prefix: \d{2}-\d{2}-\d{2} -- ]] -plugin_expression = "\n\\[\\[((.|\n)*?)\n\\]\\]"+plugin_expression = "\n\\[\\[((.|\n)*?)\\]\\]" plugin_id = "plugin" infix_of = flip isInfixOf@@ -36,7 +38,8 @@ at x xs = case (xs.lookup x) >>= parse_plugin_type of Nothing -> None Just x -> x- parse_plugin_type x = [PhotoAlbum].label_by (show_data).lookup (x)+ plugin_types = [PhotoAlbum, Video]+ parse_plugin_type x = plugin_types.label_by (show_data).lookup (x) match_result x = x.fromJust.snd.first.snd.b2u @@ -48,6 +51,8 @@ PhotoAlbum -> do album <- plugin.args.Album.from_list ^ render_plugin x.sub plugin_expression album .apply_plugin-+ Video -> do + video <- plugin.args.V.from_list ^ render_plugin+ x.sub plugin_expression video .apply_plugin -render_plugin = render_data > show+render_plugin x = x.render_data.show
+ src/Panda/View/Atom/Video.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE NoImplicitPrelude #-}+module Panda.View.Atom.Video where+ +import Panda.Helper.Env hiding (name, id)+import Panda.Model.Video+import qualified Panda.Config.Global as G+import Panda.Helper.Html++instance DataRenderer Video where+ render_data = show_video++show_video x = case x.video_type of+ MediaPlayer -> show_media_player x++show_media_player x = + [ p ! [id l] << "The player will show in this paragraph"+ , tag "script" ! [thetype "text/javascript"] << primHtml ( play (x.uid) (x.preview) (x.uid) )+ ] .toHtml+ where l = x.uid+++play i p x = + [ "var s1 = new SWFObject('/flash/player.swf','player','400','348','9');"+ , "s1.addParam('allowfullscreen','true');"+ , "s1.addParam('allowscriptaccess','always');"+ , "s1.addParam('flashvars','file=" ++ x ++ "&image=" ++ p ++ "');"+ , "s1.write('" ++ i ++ "');"+ ]+ .join "\n"+