casr-logbook-reports-meta-html (empty) → 0.0.1
raw patch · 6 files changed
+265/−0 lines, 6 filesdep +QuickCheckdep +basedep +casr-logbookbuild-type:Customsetup-changed
Dependencies added: QuickCheck, base, casr-logbook, casr-logbook-meta, casr-logbook-meta-html, casr-logbook-reports, casr-logbook-reports-html, casr-logbook-reports-meta, directory, doctest, filepath, lens, lucid, template-haskell, text
Files
- LICENSE +27/−0
- Setup.lhs +44/−0
- casr-logbook-reports-meta-html.cabal +82/−0
- changelog +4/−0
- src/Data/Aviation/Casr/Logbook/Reports/Meta/Html.hs +76/−0
- test/doctests.hs +32/−0
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright 2016 Tony Morris+All rights reserved.++Redistribution and use in source and binary forms, with or without modification,+are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+list of conditions, the following disclaimer and the following SHA-512 checksum.++2. Redistributions in binary form must reproduce the above copyright notice,+this list of conditions, the following disclaimer and the following SHA-512+checksum in the documentation and/or other materials provided with the+distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.++THIS SOFTWARE IS PROVIDED WITH A SHA-512 CHECKSUM.+ecdfdf543fd166b13b76b11e0b010e00d693028771880ffd8f9252ae0b8ac42bddf8eb7a23c21c86a3b50039d642ad9eeb7e8a0e82f6a345f60feb4a54808362
+ Setup.lhs view
@@ -0,0 +1,44 @@+#!/usr/bin/env runhaskell+\begin{code}+{-# OPTIONS_GHC -Wall #-}+module Main (main) where++import Data.List ( nub )+import Data.Version ( showVersion )+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )+import Distribution.Simple.BuildPaths ( autogenModulesDir )+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )+import Distribution.Verbosity ( Verbosity )+import System.FilePath ( (</>) )++main :: IO ()+main = defaultMainWithHooks simpleUserHooks+ { buildHook = \pkg lbi hooks flags -> do+ generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi+ buildHook simpleUserHooks pkg lbi hooks flags+ }++generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()+generateBuildModule verbosity pkg lbi = do+ let dir = autogenModulesDir lbi+ createDirectoryIfMissingVerbose verbosity True dir+ withLibLBI pkg lbi $ \_ libcfg -> do+ withTestLBI pkg lbi $ \suite suitecfg -> do+ rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines+ [ "module Build_" ++ testName suite ++ " where"+ , "deps :: [String]"+ , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))+ ]+ where+ formatdeps = map (formatone . snd)+ formatone p = case packageName p of+ PackageName n -> n ++ "-" ++ showVersion (packageVersion p)++testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys++\end{code}
+ casr-logbook-reports-meta-html.cabal view
@@ -0,0 +1,82 @@+name: casr-logbook-reports-meta-html+version: 0.0.1+license: OtherLicense+license-file: LICENSE+author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ>+maintainer: Tony Morris+copyright: Copyright (C) 2016 Tony Morris+synopsis: HTML output for reports on meta-information about entries in a CASR 61.345 logbook+category: Aviation+description: + <<https://i.imgur.com/p6LT40r.png>>+ .+ HTML output for reports on meta-information about entries in a CASR 61.345 logbook+ .+ <<https://i.imgur.com/Lfhcmtg.png>>++homepage: https://github.com/tonymorris/casr-logbook-reports-meta-html+bug-reports: https://github.com/tonymorris/casr-logbook-reports-meta-html/issues+cabal-version: >= 1.10+build-type: Custom+extra-source-files: changelog++source-repository head+ type: git+ location: git@github.com:tonymorris/casr-logbook-reports-meta-html.git++flag small_base+ description: Choose the new, split-up base package.++library+ default-language:+ Haskell2010++ build-depends:+ base < 5 && >= 4.8+ , casr-logbook >= 0.1.3 && < 0.2+ , casr-logbook-meta >= 0.0.3 && < 0.1+ , casr-logbook-meta-html >= 0.0.2 && < 0.1+ , casr-logbook-reports >= 0.0.1 && < 0.1+ , casr-logbook-reports-meta >= 0.0.2 && < 0.1+ , casr-logbook-reports-html >= 0.0.1 && < 0.1+ , lucid >= 2.9 && < 3+ , lens >= 4.1 && < 5+ , text >= 1.2 && < 1.3+ ++ ghc-options:+ -Wall++ default-extensions:+ NoImplicitPrelude++ hs-source-dirs:+ src++ exposed-modules:+ Data.Aviation.Casr.Logbook.Reports.Meta.Html++test-suite doctests+ type:+ exitcode-stdio-1.0++ main-is:+ doctests.hs++ default-language:+ Haskell2010++ build-depends:+ base < 5 && >= 3+ , doctest >= 0.9.7+ , filepath >= 1.3+ , directory >= 1.1+ , QuickCheck >= 2.0+ , template-haskell >= 2.8++ ghc-options:+ -Wall+ -threaded++ hs-source-dirs:+ test
+ changelog view
@@ -0,0 +1,4 @@+0.0.1++* Initial release+
+ src/Data/Aviation/Casr/Logbook/Reports/Meta/Html.hs view
@@ -0,0 +1,76 @@+{-# LANGUAGE OverloadedStrings #-}++module Data.Aviation.Casr.Logbook.Reports.Meta.Html(+ htmlExpenseReport+, htmlReports+) where++import Control.Category((.))+import Data.Aviation.Casr.Logbook.Reports(getFlightTimeReport, getSimulatorTimeReport)+import Data.Aviation.Casr.Logbook.Reports.Html(htmlFlightTimeReport, htmlSimulatorTimeReport, htmlTakeOffLanding90, takeoffslandings90)+import Data.Aviation.Casr.Logbook.Reports.Meta(ExpenseReport(ExpenseReport), logbookExpenseReport)+import Data.Aviation.Casr.Logbook.Meta(AircraftFlightMeta, SimulatorFlightMeta, ExamMeta, BriefingMeta)+import Data.Aviation.Casr.Logbook.Meta.Html(showThousandCentsAsDollars, showHundredCentsAsDollars)+import Data.Aviation.Casr.Logbook(Logbook)+import Data.Function(($))+import Data.String(fromString)+import qualified Data.Text as Text(pack)+import Lucid(+ hr_+ , class_+ , ul_+ , li_+ , span_+ , h3_+ , div_+ , a_+ , id_+ , href_+ , Html+ )+import Prelude((+))++htmlExpenseReport ::+ Logbook AircraftFlightMeta SimulatorFlightMeta ExamMeta BriefingMeta+ -> ExpenseReport+ -> Html ()+htmlExpenseReport _ (ExpenseReport ag al b e s) =+ div_ [class_ "expensereport"] $+ do a_ [id_ "RPT_Expense"] ""+ a_ [href_ (Text.pack ("#RPT_Expense"))] . span_ [class_ "entrytag"] $ "RPT"+ h3_ [class_ "expensereportname"] "Expense Report" + do ul_ [] $+ do li_ [] $+ do span_ [class_ "key"] "Aircraft: "+ span_ [class_ "value"] . fromString . ('$':) . showThousandCentsAsDollars $ ag + al+ ul_ [] $+ do li_ [] $+ do span_ [class_ "key"] "Usage: "+ span_ [class_ "value"] . fromString . ('$':) . showThousandCentsAsDollars $ ag+ li_ [] $+ do span_ [class_ "key"] "Landing: "+ span_ [class_ "value"] . fromString . ('$':) . showHundredCentsAsDollars $ al+ li_ [] $+ do span_ [class_ "key"] "Briefing: "+ span_ [class_ "value"] . fromString . ('$':) . showThousandCentsAsDollars $ b+ li_ [] $+ do span_ [class_ "key"] "Exam: "+ span_ [class_ "value"] . fromString . ('$':) . showHundredCentsAsDollars $ e+ li_ [] $+ do span_ [class_ "key"] "Simulator: "+ span_ [class_ "value"] . fromString . ('$':) . showThousandCentsAsDollars $ s+ li_ [] $+ do span_ [class_ "key"] "TOTAL: "+ span_ [class_ "value"] . fromString . ('$':) . showThousandCentsAsDollars $ (ag + al + b + e + s)++htmlReports ::+ Logbook AircraftFlightMeta SimulatorFlightMeta ExamMeta BriefingMeta+ -> Html ()+htmlReports b =+ do htmlFlightTimeReport b (getFlightTimeReport b)+ hr_ [] + htmlSimulatorTimeReport b (getSimulatorTimeReport b)+ hr_ [] + htmlTakeOffLanding90 b (takeoffslandings90 b)+ hr_ [] + htmlExpenseReport b (logbookExpenseReport b)
+ test/doctests.hs view
@@ -0,0 +1,32 @@+module Main where++import Build_doctests (deps)+import Control.Applicative+import Control.Monad+import Data.List+import System.Directory+import System.FilePath+import Test.DocTest++main ::+ IO ()+main =+ getSources >>= \sources -> doctest $+ "-isrc"+ : "-idist/build/autogen"+ : "-optP-include"+ : "-optPdist/build/autogen/cabal_macros.h"+ : "-hide-all-packages"+ : map ("-package="++) deps ++ sources++getSources :: IO [FilePath]+getSources = filter (isSuffixOf ".hs") <$> go "src"+ where+ go dir = do+ (dirs, files) <- getFilesAndDirectories dir+ (files ++) . concat <$> mapM go dirs++getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])+getFilesAndDirectories dir = do+ c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir+ (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c