diff --git a/old/Config.hs b/Config.hs similarity index 68% rename from old/Config.hs rename to Config.hs index ad8be6c..2a7cd5b 100644 --- a/old/Config.hs +++ b/Config.hs @@ -1,19 +1,34 @@ module Config where +{--- + - Config Module + - + - Contains settings that will effect the running of the program + - + - Shaun Kerr + -} + import System.Random import State import Timestamp import Packs +-- Earliest rotation. +-- Each format is generated starting from this date. genesis :: Timestamp genesis = Ts 29 09 1996 +-- Initial seed. +-- Keep it secret. Keep it safe. seed :: Int seed = 69420 +-- Initial RNG entropy :: StdGen entropy = mkStdGen $ seed +-- Initial rotation. +-- Simple split in half, genesis leaves plenty of time to shuffle. initialRotation :: State initialRotation = ((i, o), b, r) where diff --git a/old/Format.hs b/Format.hs similarity index 71% rename from old/Format.hs rename to Format.hs index a1f442a..a268dbb 100644 --- a/old/Format.hs +++ b/Format.hs @@ -1,16 +1,27 @@ module Format where +{--- + - Format Module + - + - Functions for generating new formats + - Little bit of a shitshow + - + - Shaun Kerr + -} + import System.Random import State import Timestamp import Config import Utils +-- Calculate the format starting from Genesis currentFormat :: Timestamp -> State currentFormat t = strictApplyN n nextFormat initialRotation where n = t `monthsSince` genesis +-- Take a format and return the next months format nextFormat :: State -> State nextFormat (p, b, r) = (np, nb, nr) where @@ -18,18 +29,23 @@ nextFormat (p, b, r) = (np, nb, nr) (np, nr) = (addNewPack . addNewPack) (ip, r) nb = rotateBox b +-- Returns the out rotation packs that are legal legalOutRot :: [OutRot] -> [OutRot] legalOutRot x = filter (\(Or _ n) -> n == 0) x +-- Updates out rotation pack legality updatePackAge :: [OutRot] -> [OutRot] updatePackAge p = map (\(Or s n) -> (Or s $ max 0 (n-1))) p +-- Illegalise a pack setIllegal :: InRot -> OutRot setIllegal (Ir n) = Or n 3 +-- Legalise a pack setLegal :: OutRot -> InRot setLegal (Or n _) = Ir n +-- Drop two oldest packs rotateOld :: Pool -> Pool rotateOld (i, o) = (ni, no) where @@ -37,6 +53,7 @@ rotateOld (i, o) = (ni, no) no = (updatePackAge o) ++ dropped dropped = map setIllegal (take 2 i) +-- Add a new pack addNewPack :: (Pool, StdGen) -> (Pool, StdGen) addNewPack ((i, o), r) = ((ni, no), nr) where @@ -46,5 +63,6 @@ addNewPack ((i, o), r) = ((ni, no), nr) ni = i ++ [(setLegal np)] no = filter (\x -> x /= np) o +-- Update the banned box rotateBox :: BoxQueue -> BoxQueue rotateBox (Bq x) = Bq $ rotate 1 x diff --git a/old/Packs.hs b/Packs.hs similarity index 93% rename from old/Packs.hs rename to Packs.hs index 356ad2e..638af92 100644 --- a/old/Packs.hs +++ b/Packs.hs @@ -1,5 +1,14 @@ module Packs where +{--- + - Pack Module + - + - Defines datatypes for each pack and I totally didn't + - hand code this nuh-uh for real + - + - Shaun Kerr + -} + data BigBox = Cc | Hp | Oc | Dd | Td | Rr deriving Eq diff --git a/State.hs b/State.hs new file mode 100644 index 0000000..75f947d --- /dev/null +++ b/State.hs @@ -0,0 +1,41 @@ +module State where + +{--- + - State Module + - + - Functions used for creating and defining the + - state of the current rotation. + - + - Shaun Kerr. + -} + +import System.Random +import Packs + +-- Total State is the Datapack Pool, the Banned Big Box, +-- and the next random number. +type State = (Pool, BoxQueue, StdGen) + +-- In Rotation packs have no metadata +data InRot = Ir DataPack deriving (Show, Eq) + +-- Out Rotation packs need a number of months +-- until they're legal again. +data OutRot = Or DataPack Integer +instance Eq OutRot where + (Or d1 _) == (Or d2 _) = d1 == d2 + +-- Box Queue is full of Maybes for the month +-- where none are banned. +data BoxQueue = Bq [Maybe BigBox] + +-- Total pool is split into in and out of rotation +type Pool = ([InRot], [OutRot]) + +-- Simple Wrapper +createInRot :: [DataPack] -> [InRot] +createInRot x = map (\n -> Ir n) x + +-- Wrapper + Initial legality +createOutRot :: [DataPack] -> [OutRot] +createOutRot x = map (\n -> Or n 0) x diff --git a/Timestamp.hs b/Timestamp.hs index 6139dfd..7ae634d 100644 --- a/Timestamp.hs +++ b/Timestamp.hs @@ -1,10 +1,25 @@ module Timestamp where +{--- + - Timestamp Module + - + - Functions related to getting and using timestamps. + - + - Shaun Kerr + -} + +import Data.Time.LocalTime +import Data.Time.Format + +-- Internal Date Representation data Timestamp = Ts Integer Integer Integer deriving Show +-- Previews Start on the 20th isPreviewSeason :: Timestamp -> Bool isPreviewSeason (Ts x _ _) = x >= 20 +-- True // False if first date is in the future +-- relative to the second date. inFuture :: Timestamp -> Timestamp -> Bool inFuture (Ts d1 m1 y1) (Ts d2 m2 y2) | y1 /= y2 = y1 > y2 @@ -12,6 +27,9 @@ inFuture (Ts d1 m1 y1) (Ts d2 m2 y2) | d1 /= d2 = d1 > d2 | otherwise = False +-- How many months in the future the first date is +-- relative from the second date. +-- returns 0 otherwise. monthsSince :: Timestamp -> Timestamp -> Integer monthsSince (Ts d1 m1 y1) (Ts d2 m2 y2) | t1 `inFuture` t2 = (12 * (y1 - y2)) + (m1 - m2) @@ -20,14 +38,22 @@ monthsSince (Ts d1 m1 y1) (Ts d2 m2 y2) t1 = Ts d1 m1 y1 t2 = Ts d2 m2 y2 +-- Helper, format Integer representation to Timestamp toTS :: (Integer, Integer, Integer) -> Timestamp toTS (y,m,d) = Ts d m y +-- IO Function, get the current date as a [Char] getCurrentTime :: IO [Char] getCurrentTime = getZonedTime >>= return . (formatTime defaultTimeLocale "%Y %m %d") +-- Helper, format the [Char] as triple Integer fmtCurrentTime :: [Char] -> (Integer, Integer, Integer) fmtCurrentTime n = (\[a,b,c] -> (a,b,c)) iTime where iTime = map (\x -> read x :: Integer) $ words n + +-- Hide away some ugly steps. Not sure we ever +-- use the other two so can probably compact this. +getTimestamp :: [Char] -> Timestamp +getTimestamp x = toTS . fmtCurrentTime $ x diff --git a/ViewUtils.hs b/ViewUtils.hs index 1be68f8..009893b 100644 --- a/ViewUtils.hs +++ b/ViewUtils.hs @@ -1,5 +1,14 @@ module ViewUtils where +{--- + - ViewUtils Module + - + - Your guess is as good as mine why this is its own thing + - gotta get the month I guess + - + - Shaun Kerr + -} + import Timestamp showMonth :: Integer -> String @@ -15,5 +24,3 @@ showMonth 9 = "September" showMonth 10 = "October" showMonth 11 = "November" showMonth 12 = "December" - - diff --git a/ChangeLog.md b/old/ChangeLog.md similarity index 100% rename from ChangeLog.md rename to old/ChangeLog.md diff --git a/Setup.hs b/old/Setup.hs_ similarity index 100% rename from Setup.hs rename to old/Setup.hs_ diff --git a/old/State.hs b/old/State.hs deleted file mode 100644 index 09b3d3e..0000000 --- a/old/State.hs +++ /dev/null @@ -1,22 +0,0 @@ -module State where - -import System.Random -import Packs - -type State = (Pool, BoxQueue, StdGen) - -data InRot = Ir DataPack deriving (Show, Eq) - -data OutRot = Or DataPack Integer -instance Eq OutRot where - (Or d1 _) == (Or d2 _) = d1 == d2 - -data BoxQueue = Bq [Maybe BigBox] - -type Pool = ([InRot], [OutRot]) - -createInRot :: [DataPack] -> [InRot] -createInRot x = map (\n -> Ir n) x - -createOutRot :: [DataPack] -> [OutRot] -createOutRot x = map (\n -> Or n 0) x diff --git a/_cache/02ffd36321aca0d8196095fa897a7038 b/old/_cache/02ffd36321aca0d8196095fa897a7038 similarity index 100% rename from _cache/02ffd36321aca0d8196095fa897a7038 rename to old/_cache/02ffd36321aca0d8196095fa897a7038 diff --git a/_cache/12991168de6a9db452e49f2814dc4837 b/old/_cache/12991168de6a9db452e49f2814dc4837 similarity index 100% rename from _cache/12991168de6a9db452e49f2814dc4837 rename to old/_cache/12991168de6a9db452e49f2814dc4837 diff --git a/_cache/13318c2b4a591b8f412f367f81df20d6 b/old/_cache/13318c2b4a591b8f412f367f81df20d6 similarity index 100% rename from _cache/13318c2b4a591b8f412f367f81df20d6 rename to old/_cache/13318c2b4a591b8f412f367f81df20d6 diff --git a/_cache/18bc831854684ac860e2cfa4e9301159 b/old/_cache/18bc831854684ac860e2cfa4e9301159 similarity index 100% rename from _cache/18bc831854684ac860e2cfa4e9301159 rename to old/_cache/18bc831854684ac860e2cfa4e9301159 diff --git a/_cache/21253358050819032165ae7515d3cfb6 b/old/_cache/21253358050819032165ae7515d3cfb6 similarity index 100% rename from _cache/21253358050819032165ae7515d3cfb6 rename to old/_cache/21253358050819032165ae7515d3cfb6 diff --git a/_cache/2c4bf143a0d65180ae3fe8595281bb5d b/old/_cache/2c4bf143a0d65180ae3fe8595281bb5d similarity index 100% rename from _cache/2c4bf143a0d65180ae3fe8595281bb5d rename to old/_cache/2c4bf143a0d65180ae3fe8595281bb5d diff --git a/_cache/2cc6229282889d93740fc5c44e426c43 b/old/_cache/2cc6229282889d93740fc5c44e426c43 similarity index 100% rename from _cache/2cc6229282889d93740fc5c44e426c43 rename to old/_cache/2cc6229282889d93740fc5c44e426c43 diff --git a/_cache/3234241ee02d543d0cdc0eecf6b7f701 b/old/_cache/3234241ee02d543d0cdc0eecf6b7f701 similarity index 100% rename from _cache/3234241ee02d543d0cdc0eecf6b7f701 rename to old/_cache/3234241ee02d543d0cdc0eecf6b7f701 diff --git a/_cache/3502f2aa291df768b503711e91da7f94 b/old/_cache/3502f2aa291df768b503711e91da7f94 similarity index 100% rename from _cache/3502f2aa291df768b503711e91da7f94 rename to old/_cache/3502f2aa291df768b503711e91da7f94 diff --git a/_cache/36f9964be8b4f357c1d80cfdc525df89 b/old/_cache/36f9964be8b4f357c1d80cfdc525df89 similarity index 100% rename from _cache/36f9964be8b4f357c1d80cfdc525df89 rename to old/_cache/36f9964be8b4f357c1d80cfdc525df89 diff --git a/_cache/3aa7c8fae80d374ec9a40c7a9116a08f b/old/_cache/3aa7c8fae80d374ec9a40c7a9116a08f similarity index 100% rename from _cache/3aa7c8fae80d374ec9a40c7a9116a08f rename to old/_cache/3aa7c8fae80d374ec9a40c7a9116a08f diff --git a/_cache/41623fed16032ec0baf01c53a86cce9f b/old/_cache/41623fed16032ec0baf01c53a86cce9f similarity index 100% rename from _cache/41623fed16032ec0baf01c53a86cce9f rename to old/_cache/41623fed16032ec0baf01c53a86cce9f diff --git a/_cache/5186f0e1b9013dffb631b7ac1daee0ff b/old/_cache/5186f0e1b9013dffb631b7ac1daee0ff similarity index 100% rename from _cache/5186f0e1b9013dffb631b7ac1daee0ff rename to old/_cache/5186f0e1b9013dffb631b7ac1daee0ff diff --git a/_cache/58a0023be224362f3c70e834c2890dab b/old/_cache/58a0023be224362f3c70e834c2890dab similarity index 100% rename from _cache/58a0023be224362f3c70e834c2890dab rename to old/_cache/58a0023be224362f3c70e834c2890dab diff --git a/_cache/5a2f2185fd6eb7526e285f6845fb2711 b/old/_cache/5a2f2185fd6eb7526e285f6845fb2711 similarity index 100% rename from _cache/5a2f2185fd6eb7526e285f6845fb2711 rename to old/_cache/5a2f2185fd6eb7526e285f6845fb2711 diff --git a/_cache/5e52357749f41a8425ceca375f580db8 b/old/_cache/5e52357749f41a8425ceca375f580db8 similarity index 100% rename from _cache/5e52357749f41a8425ceca375f580db8 rename to old/_cache/5e52357749f41a8425ceca375f580db8 diff --git a/_cache/65d86825c80bb51fe28215cbbdc72f9c b/old/_cache/65d86825c80bb51fe28215cbbdc72f9c similarity index 100% rename from _cache/65d86825c80bb51fe28215cbbdc72f9c rename to old/_cache/65d86825c80bb51fe28215cbbdc72f9c diff --git a/_cache/6b13d4c109d24e3df78f6283afdafd71 b/old/_cache/6b13d4c109d24e3df78f6283afdafd71 similarity index 100% rename from _cache/6b13d4c109d24e3df78f6283afdafd71 rename to old/_cache/6b13d4c109d24e3df78f6283afdafd71 diff --git a/_cache/74ad07f6399cddcf5e93a42176e6ff4a b/old/_cache/74ad07f6399cddcf5e93a42176e6ff4a similarity index 100% rename from _cache/74ad07f6399cddcf5e93a42176e6ff4a rename to old/_cache/74ad07f6399cddcf5e93a42176e6ff4a diff --git a/_cache/7a9e11cb9751d5e2c28f172e49a740f3 b/old/_cache/7a9e11cb9751d5e2c28f172e49a740f3 similarity index 100% rename from _cache/7a9e11cb9751d5e2c28f172e49a740f3 rename to old/_cache/7a9e11cb9751d5e2c28f172e49a740f3 diff --git a/_cache/7eebc8997569f57e9fd6bcfa43ee6244 b/old/_cache/7eebc8997569f57e9fd6bcfa43ee6244 similarity index 100% rename from _cache/7eebc8997569f57e9fd6bcfa43ee6244 rename to old/_cache/7eebc8997569f57e9fd6bcfa43ee6244 diff --git a/_cache/81d1b6c2c1cab5cdfc34988853034e75 b/old/_cache/81d1b6c2c1cab5cdfc34988853034e75 similarity index 100% rename from _cache/81d1b6c2c1cab5cdfc34988853034e75 rename to old/_cache/81d1b6c2c1cab5cdfc34988853034e75 diff --git a/_cache/8202fa021d8183dcb2050787d67fa9ed b/old/_cache/8202fa021d8183dcb2050787d67fa9ed similarity index 100% rename from _cache/8202fa021d8183dcb2050787d67fa9ed rename to old/_cache/8202fa021d8183dcb2050787d67fa9ed diff --git a/_cache/8c2cc830d6d96619afd7f817c883e2cb b/old/_cache/8c2cc830d6d96619afd7f817c883e2cb similarity index 100% rename from _cache/8c2cc830d6d96619afd7f817c883e2cb rename to old/_cache/8c2cc830d6d96619afd7f817c883e2cb diff --git a/_cache/8e5ffdf6c89ed1aa49301aa3a00a2add b/old/_cache/8e5ffdf6c89ed1aa49301aa3a00a2add similarity index 100% rename from _cache/8e5ffdf6c89ed1aa49301aa3a00a2add rename to old/_cache/8e5ffdf6c89ed1aa49301aa3a00a2add diff --git a/_cache/9861f58ae8a49766ccd8f33085c3ba42 b/old/_cache/9861f58ae8a49766ccd8f33085c3ba42 similarity index 100% rename from _cache/9861f58ae8a49766ccd8f33085c3ba42 rename to old/_cache/9861f58ae8a49766ccd8f33085c3ba42 diff --git a/_cache/a2e2c78a44d784b0fd8ff02b6324dc02 b/old/_cache/a2e2c78a44d784b0fd8ff02b6324dc02 similarity index 100% rename from _cache/a2e2c78a44d784b0fd8ff02b6324dc02 rename to old/_cache/a2e2c78a44d784b0fd8ff02b6324dc02 diff --git a/_cache/a8e78f0ff3815d8ef9ed987a4625aeb3 b/old/_cache/a8e78f0ff3815d8ef9ed987a4625aeb3 similarity index 100% rename from _cache/a8e78f0ff3815d8ef9ed987a4625aeb3 rename to old/_cache/a8e78f0ff3815d8ef9ed987a4625aeb3 diff --git a/_cache/b324eb6b5a5bbd10b5a71240f7edcd71 b/old/_cache/b324eb6b5a5bbd10b5a71240f7edcd71 similarity index 100% rename from _cache/b324eb6b5a5bbd10b5a71240f7edcd71 rename to old/_cache/b324eb6b5a5bbd10b5a71240f7edcd71 diff --git a/_cache/b55ed8f8472b848711dbd0caa2920e4f b/old/_cache/b55ed8f8472b848711dbd0caa2920e4f similarity index 100% rename from _cache/b55ed8f8472b848711dbd0caa2920e4f rename to old/_cache/b55ed8f8472b848711dbd0caa2920e4f diff --git a/_cache/c24ef28b2ac6c9fe797b11c5d68599ff b/old/_cache/c24ef28b2ac6c9fe797b11c5d68599ff similarity index 100% rename from _cache/c24ef28b2ac6c9fe797b11c5d68599ff rename to old/_cache/c24ef28b2ac6c9fe797b11c5d68599ff diff --git a/_cache/cedbb457a9c3e70e2341381194664a42 b/old/_cache/cedbb457a9c3e70e2341381194664a42 similarity index 100% rename from _cache/cedbb457a9c3e70e2341381194664a42 rename to old/_cache/cedbb457a9c3e70e2341381194664a42 diff --git a/_cache/d5c19886a5497f571c624d44ba520d2b b/old/_cache/d5c19886a5497f571c624d44ba520d2b similarity index 100% rename from _cache/d5c19886a5497f571c624d44ba520d2b rename to old/_cache/d5c19886a5497f571c624d44ba520d2b diff --git a/_cache/dbb2e29497bc6a4d9f381f8003dc0e29 b/old/_cache/dbb2e29497bc6a4d9f381f8003dc0e29 similarity index 100% rename from _cache/dbb2e29497bc6a4d9f381f8003dc0e29 rename to old/_cache/dbb2e29497bc6a4d9f381f8003dc0e29 diff --git a/_cache/e4b9b8633ce1170f36e573786e855a55 b/old/_cache/e4b9b8633ce1170f36e573786e855a55 similarity index 100% rename from _cache/e4b9b8633ce1170f36e573786e855a55 rename to old/_cache/e4b9b8633ce1170f36e573786e855a55 diff --git a/_cache/ed9c302a44a035e5579daccaf55007fa b/old/_cache/ed9c302a44a035e5579daccaf55007fa similarity index 100% rename from _cache/ed9c302a44a035e5579daccaf55007fa rename to old/_cache/ed9c302a44a035e5579daccaf55007fa diff --git a/_cache/f38c8240d33ea73352ba3bbc7036a71f b/old/_cache/f38c8240d33ea73352ba3bbc7036a71f similarity index 100% rename from _cache/f38c8240d33ea73352ba3bbc7036a71f rename to old/_cache/f38c8240d33ea73352ba3bbc7036a71f diff --git a/_site/about/index.html b/old/_site/about/index.html similarity index 100% rename from _site/about/index.html rename to old/_site/about/index.html diff --git a/_site/contact/index.html b/old/_site/contact/index.html similarity index 100% rename from _site/contact/index.html rename to old/_site/contact/index.html diff --git a/_site/css/default.css b/old/_site/css/default.css similarity index 100% rename from _site/css/default.css rename to old/_site/css/default.css diff --git a/_site/description/index.html b/old/_site/description/index.html similarity index 100% rename from _site/description/index.html rename to old/_site/description/index.html diff --git a/_site/humans.txt b/old/_site/humans.txt similarity index 100% rename from _site/humans.txt rename to old/_site/humans.txt diff --git a/_site/robots.txt b/old/_site/robots.txt similarity index 100% rename from _site/robots.txt rename to old/_site/robots.txt diff --git a/about.md b/old/about.md similarity index 100% rename from about.md rename to old/about.md diff --git a/contact.md b/old/contact.md similarity index 100% rename from contact.md rename to old/contact.md diff --git a/css/default.css b/old/css/default.css similarity index 100% rename from css/default.css rename to old/css/default.css diff --git a/default.nix b/old/default.nix similarity index 100% rename from default.nix rename to old/default.nix diff --git a/description.md b/old/description.md similarity index 100% rename from description.md rename to old/description.md diff --git a/humans.txt b/old/humans.txt similarity index 100% rename from humans.txt rename to old/humans.txt diff --git a/icons/favicon.svg b/old/icons/favicon.svg similarity index 100% rename from icons/favicon.svg rename to old/icons/favicon.svg diff --git a/p7.cabal b/old/p7.cabal similarity index 100% rename from p7.cabal rename to old/p7.cabal diff --git a/p7.nix b/old/p7.nix similarity index 100% rename from p7.nix rename to old/p7.nix diff --git a/rf.nix b/old/rf.nix similarity index 100% rename from rf.nix rename to old/rf.nix diff --git a/robots.txt b/old/robots.txt similarity index 100% rename from robots.txt rename to old/robots.txt diff --git a/shell.nix b/old/shell.nix similarity index 100% rename from shell.nix rename to old/shell.nix diff --git a/site.hs b/old/site.hs similarity index 95% rename from site.hs rename to old/site.hs index 462ba75..9d22821 100644 --- a/site.hs +++ b/old/site.hs @@ -47,10 +47,12 @@ ctx = defaultContext <> -- Default context for format fmtCtx :: Integer -> Integer -> String -> Context String -fmtCtx m y u = +fmtCtx m y u dps bbs = (titleField mTitle) <> (field "nrdbUrl" u) <> - (listFieldWith + (listField "dpacks" ( + field "dp" (return . + ) ctx where mTitle = "Format for " ++ (showMonth m) ++ " " ++ y diff --git a/templates/archive.html b/old/templates/archive.html similarity index 100% rename from templates/archive.html rename to old/templates/archive.html diff --git a/templates/default.html b/old/templates/default.html similarity index 100% rename from templates/default.html rename to old/templates/default.html diff --git a/templates/format.html b/old/templates/format.html similarity index 100% rename from templates/format.html rename to old/templates/format.html diff --git a/templates/index.html b/old/templates/index.html similarity index 100% rename from templates/index.html rename to old/templates/index.html diff --git a/templates/post-list.html b/old/templates/post-list.html similarity index 100% rename from templates/post-list.html rename to old/templates/post-list.html diff --git a/templates/post.html b/old/templates/post.html similarity index 100% rename from templates/post.html rename to old/templates/post.html