From 7c1bd41fddb7be48f14145e5f18a93f516ec28f6 Mon Sep 17 00:00:00 2001 From: lijerom Date: Sat, 5 May 2018 13:49:13 -0700 Subject: [PATCH] Migrated to use my new html-generator tool! --- .gitignore | 3 + .gitmodules | 3 + build-site-no-sitemap.sh | 3 + build-site.sh | 3 + gow/index.hs | 15 +++++ index.hs | 20 +++++++ index.xhtml | 32 ---------- res/icon/icon/ICON-LICENSE | 21 +++++++ res/icon/icon/clock.svg | 3 + res/icon/icon/double-quote-serif-left.svg | 3 + res/icon/icon/double-quote-serif-right.svg | 3 + res/icon/icon/person.svg | 3 + sitemap.xml | 9 --- template.xhtml | 48 --------------- templates/.gitignore | 22 +++++++ templates/Setup.hs | 2 + templates/html-generator | 1 + templates/src/Templates.hs | 70 ++++++++++++++++++++++ templates/src/Templates/Icons.hs | 45 ++++++++++++++ templates/src/Templates/Urls.hs | 22 +++++++ templates/stack.yaml | 66 ++++++++++++++++++++ templates/templates.cabal | 25 ++++++++ 22 files changed, 333 insertions(+), 89 deletions(-) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100755 build-site-no-sitemap.sh create mode 100755 build-site.sh create mode 100644 gow/index.hs create mode 100644 index.hs delete mode 100644 index.xhtml create mode 100644 res/icon/icon/ICON-LICENSE create mode 100644 res/icon/icon/clock.svg create mode 100644 res/icon/icon/double-quote-serif-left.svg create mode 100644 res/icon/icon/double-quote-serif-right.svg create mode 100644 res/icon/icon/person.svg delete mode 100755 sitemap.xml delete mode 100755 template.xhtml create mode 100644 templates/.gitignore create mode 100644 templates/Setup.hs create mode 160000 templates/html-generator create mode 100644 templates/src/Templates.hs create mode 100644 templates/src/Templates/Icons.hs create mode 100644 templates/src/Templates/Urls.hs create mode 100644 templates/stack.yaml create mode 100644 templates/templates.cabal diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1645607 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +*.xhtml +*.xml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f494bfe --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "templates/html-generator"] + path = templates/html-generator + url = https://github.com/lijerom/html-generator diff --git a/build-site-no-sitemap.sh b/build-site-no-sitemap.sh new file mode 100755 index 0000000..4da6689 --- /dev/null +++ b/build-site-no-sitemap.sh @@ -0,0 +1,3 @@ +cd templates/ +stack exec html-generator -- $(find .. -type f -name "*.hs" | grep -v "./templates") +cd .. diff --git a/build-site.sh b/build-site.sh new file mode 100755 index 0000000..5d49c79 --- /dev/null +++ b/build-site.sh @@ -0,0 +1,3 @@ +cd templates/ +stack exec html-generator -- --sitemap $(find .. -type f -name "*.hs" | grep -v "./templates") +cd .. diff --git a/gow/index.hs b/gow/index.hs new file mode 100644 index 0000000..e7bb549 --- /dev/null +++ b/gow/index.hs @@ -0,0 +1,15 @@ +module Page where + +import Templates + +import HtmlGen.Sitemap +import HtmlGen.Html + +sitemap :: Sitemap +sitemap = baseSitemap "https://lijero.co/gow/" + `withChangeFreq` "never" + `withPriority` "0.0" + `withLastMod` "2018-05-05" + +page :: Html +page = redirectPage "The Grapes of Wrath (Audio) playlist" "https://www.youtube.com/playlist?list=PL0_-F4mPidOAXcnn9bBhaZ8byRyC4FyRyC4FpvC" diff --git a/index.hs b/index.hs new file mode 100644 index 0000000..73266b9 --- /dev/null +++ b/index.hs @@ -0,0 +1,20 @@ +module Page where + +import Templates + +import HtmlGen.Html +import HtmlGen.Tags +import HtmlGen.Sitemap + +sitemap :: Sitemap +sitemap = baseSitemap "https://lijero.co/index.xhtml" `withLastMod` "2018-05-05" + +page :: Html +page = simplePage "Lijero" "Lijero" "2018-05-05" $ + article + %> (h1 %>> "Home Page") + %> (p %>> "Sorry! This site is currently under construction.") + %> (h2 %>> "Lorem Ipsum") + %> (p %>> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") + %> (p %>> "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?") + %> (p %>> "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.") diff --git a/index.xhtml b/index.xhtml deleted file mode 100644 index 9614142..0000000 --- a/index.xhtml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - Lijero - - - - - - - - -
-
-

Home Page

-
-

Sorry! This site is under construction.

-
- - - diff --git a/res/icon/icon/ICON-LICENSE b/res/icon/icon/ICON-LICENSE new file mode 100644 index 0000000..2199f4a --- /dev/null +++ b/res/icon/icon/ICON-LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Waybury + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/res/icon/icon/clock.svg b/res/icon/icon/clock.svg new file mode 100644 index 0000000..058e443 --- /dev/null +++ b/res/icon/icon/clock.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/res/icon/icon/double-quote-serif-left.svg b/res/icon/icon/double-quote-serif-left.svg new file mode 100644 index 0000000..3e04ae6 --- /dev/null +++ b/res/icon/icon/double-quote-serif-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/res/icon/icon/double-quote-serif-right.svg b/res/icon/icon/double-quote-serif-right.svg new file mode 100644 index 0000000..9d38e9e --- /dev/null +++ b/res/icon/icon/double-quote-serif-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/res/icon/icon/person.svg b/res/icon/icon/person.svg new file mode 100644 index 0000000..a9396b2 --- /dev/null +++ b/res/icon/icon/person.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml deleted file mode 100755 index 325a164..0000000 --- a/sitemap.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - https://lijero.co/ - 2017-10-03 - monthly - 0.8 - - diff --git a/template.xhtml b/template.xhtml deleted file mode 100755 index 9d09752..0000000 --- a/template.xhtml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - Lijero - - - - - - - - -
-
-

Test Content

-
- -
- - - diff --git a/templates/.gitignore b/templates/.gitignore new file mode 100644 index 0000000..82f3a88 --- /dev/null +++ b/templates/.gitignore @@ -0,0 +1,22 @@ +dist +dist-* +cabal-dev +*.o +*.hi +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* diff --git a/templates/Setup.hs b/templates/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/templates/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/templates/html-generator b/templates/html-generator new file mode 160000 index 0000000..43d556c --- /dev/null +++ b/templates/html-generator @@ -0,0 +1 @@ +Subproject commit 43d556c89301d850da7f9e832811691daf506bf1 diff --git a/templates/src/Templates.hs b/templates/src/Templates.hs new file mode 100644 index 0000000..593315e --- /dev/null +++ b/templates/src/Templates.hs @@ -0,0 +1,70 @@ +module Templates where + +import Templates.Urls +import Templates.Icons + +import HtmlGen.Html +import HtmlGen.Tags + +basePage :: String -> String -> Html -> Html +basePage pageTitle authorName content = + html %% xmlns %% langEn + %> (headTag + %> utf8 + %> author authorName + %> allowRobots + %> stylesheet stylesheetCommonUrl + %> faviconLink + %> (title %>> pageTitle) + %> viewport + ) + %> content + +navSection :: Html +navSection = + nav + %> (spanTag `withId` "navbrand" %>> "Lijero") + %> unorderedList + [ href baseUrl $ text "Home" + , href qiplUrl $ text "Qipl" + , href aboutUrl $ text "About" + ] + +footerSection :: String -> String -> Html +footerSection authorName dateModified = + footer + %> (divTag `withClass` "metadata" + %> (spanTag + %> authorIcon + %>> ' ' : authorName + ) + %> (spanTag + %> updatedIcon + %>> ' ' : dateModified + ) + %> license + ) + +simplePage :: String -> String -> String -> Html -> Html +simplePage titleName authorName dateModified content = + basePage titleName authorName $ + body %> navSection + %> content + %> footerSection authorName dateModified + +redirectPage :: String -> String -> Html +redirectPage name url = + html + %> (headTag + %> utf8 + %> (meta + %% ("http-equiv", "refresh") + %% ("content", "0;url=" ++ url) + ) + %> (title %>> "Redirecting to " ++ url) + ) + %> (body + %> (href url $ p + %>> ("Click here if you are not being redirected to " ++ name) + ) + ) diff --git a/templates/src/Templates/Icons.hs b/templates/src/Templates/Icons.hs new file mode 100644 index 0000000..a8adc03 --- /dev/null +++ b/templates/src/Templates/Icons.hs @@ -0,0 +1,45 @@ +module Templates.Icons where + +import Templates.Urls + +import HtmlGen.Html +import HtmlGen.Tags + +personIconUrl :: String +personIconUrl = iconUrl ++ "person.svg" + +personIcon :: String -> Html +personIcon alt = img alt personIconUrl + +authorIcon :: Html +authorIcon = personIcon "Author" + +clockIconUrl :: String +clockIconUrl = iconUrl ++ "clock.svg" + +clockIcon :: String -> Html +clockIcon alt = img alt clockIconUrl + +updatedIcon :: Html +updatedIcon = clockIcon "Updated" + +ccbysaIconUrl :: String +ccbysaIconUrl = resUrl ++ "cc-by-sa-small.png" + +ccbysaIcon :: Html +ccbysaIcon = img "This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License" ccbysaIconUrl %% ("style", "border-width:0") + +license :: Html +license = + divTag `withClass` "license" + %> (href ccbysaUrl ccbysaIcon + %% ("rel", "license")) + +faviconUrl :: String +faviconUrl = baseUrl ++ "favicon.png" + +faviconMime :: String +faviconMime = "image/png" + +faviconLink :: Html +faviconLink = favicon faviconUrl faviconMime diff --git a/templates/src/Templates/Urls.hs b/templates/src/Templates/Urls.hs new file mode 100644 index 0000000..e99ed05 --- /dev/null +++ b/templates/src/Templates/Urls.hs @@ -0,0 +1,22 @@ +module Templates.Urls where + +baseUrl :: String +baseUrl = "//lijero.co/" + +resUrl :: String +resUrl = baseUrl ++ "res/" + +iconUrl :: String +iconUrl = resUrl ++ "icon/" + +ccbysaUrl :: String +ccbysaUrl = "http://creativecommons.org/licenses/by-sa/4.0/" + +stylesheetCommonUrl :: String +stylesheetCommonUrl = resUrl ++ "common.css" + +qiplUrl :: String +qiplUrl = baseUrl ++ "qipl/" + +aboutUrl :: String +aboutUrl = baseUrl ++ "about/" diff --git a/templates/stack.yaml b/templates/stack.yaml new file mode 100644 index 0000000..b6befb2 --- /dev/null +++ b/templates/stack.yaml @@ -0,0 +1,66 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# resolver: ghcjs-0.1.0_ghc-7.10.2 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# resolver: ./custom-snapshot.yaml +# resolver: https://example.com/snapshots/2018-01-01.yaml +resolver: lts-11.7 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# subdirs: +# - auto-update +# - wai +packages: +- . +- html-generator +# Dependency packages to be pulled from upstream that are not in the resolver +# using the same syntax as the packages field. +# (e.g., acme-missiles-0.3) +# extra-deps: [] + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.7" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor diff --git a/templates/templates.cabal b/templates/templates.cabal new file mode 100644 index 0000000..97ae233 --- /dev/null +++ b/templates/templates.cabal @@ -0,0 +1,25 @@ +name: templates +version: 0.1.0.0 +-- synopsis: +-- description: +homepage: https://github.com/lijerom/lijero.co/ +license: GPL-3 +--license-file: LICENSE +author: Lijero +maintainer: lijero@lijero.co +copyright: 2018 Lijero +category: Web +build-type: Simple +cabal-version: >=1.10 +-- extra-source-files: README.md + +library + hs-source-dirs: src + default-language: Haskell2010 + exposed-modules: + Templates + , Templates.Icons + , Templates.Urls + build-depends: + base >=4.7 && <5 + , html-generator