Skip to content

Commit 8126429

Browse files
Release 0.3.0.0
2 parents ff4aecf + bfa85f6 commit 8126429

28 files changed

+2044
-553
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ following conventions:
2424

2525
[KaC]: <https://keepachangelog.com/en/1.0.0/>
2626

27+
## 0.3.0.0 (2020-08-23)
28+
29+
### Breaking
30+
31+
* Add default section support
32+
* Add top-level queues array support
33+
* Add import support
34+
* Add user-defined tag support
35+
* Remove split property
36+
* Change templates to use snake-case properties
37+
2738
## 0.2.0.0 (2020-08-11)
2839

2940
### Breaking

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ clean-all: clean # clean package and remove artifacts
7070
> @rm -f *.yaml.lock
7171
.PHONY: clean-all
7272

73+
coverage: # run tests with code coverage *
74+
> @command -v hr >/dev/null 2>&1 && hr -t || true
75+
> @stack test --coverage $(RESOLVER_ARGS) $(STACK_YAML_ARGS) $(NIX_PATH_ARGS)
76+
> @stack hpc report .
77+
.PHONY: coverage
78+
# https://github.com/commercialhaskell/stack/issues/1305
79+
7380
grep: # grep all non-hidden files for expression E
7481
> $(eval E:= "")
7582
> @test -n "$(E)" || $(call die,"usage: make grep E=expression")
@@ -205,7 +212,9 @@ todo: # search for TODO items
205212
> -not -path './build/*' \
206213
> -not -path './project/*' \
207214
> -not -path ./Makefile \
208-
> | xargs grep -Hn TODO || true
215+
> | xargs grep -Hn TODO \
216+
> | grep -v '^Binary file ' \
217+
> || true
209218
.PHONY: todo
210219

211220
version: # show current version

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
## Overview
1717

1818
Queue Sheet is a utility that builds PDFs of lists. Printed PDFs can be used
19-
to track progress when offline. Optionally include URLs when sharing a PDF
20-
with others so that they can easily access the media.
19+
to track progress when offline.
2120

2221
Use Queue Sheet to track:
2322

@@ -53,12 +52,13 @@ $ stack install
5352

5453
See the [`queue-sheet` man page](doc/queue-sheet.1.md) for usage information.
5554

56-
See the [example](example) directory for example files and output.
55+
See the [examples](examples) directory for example queue files, templates, and
56+
built output.
5757

5858
## Project
5959

6060
Queue Sheet was written quickly to solve a particular pain point. There are
61-
no plans to expose a library or put the package on Hackage.
61+
no plans to put the package on Hackage.
6262

6363
### Links
6464

File renamed without changes.

app/queue-sheet.hs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
------------------------------------------------------------------------------
2+
-- |
3+
-- Module : Main
4+
-- Description : queue-sheet program
5+
-- Copyright : Copyright (c) 2020 Travis Cardwell
6+
-- License : MIT
7+
------------------------------------------------------------------------------
8+
9+
{-# LANGUAGE RecordWildCards #-}
10+
11+
module Main (main) where
12+
13+
-- https://hackage.haskell.org/package/base
14+
import Control.Applicative (optional)
15+
import System.Exit (exitFailure)
16+
17+
-- https://hackage.haskell.org/package/optparse-applicative
18+
import qualified Options.Applicative as OA
19+
20+
-- (queue-sheet)
21+
import QueueSheet (version)
22+
import QueueSheet.Build (buildPdf)
23+
24+
-- (queue-sheet:executable)
25+
import qualified LibOA
26+
27+
------------------------------------------------------------------------------
28+
-- $Constants
29+
30+
-- | Default template file
31+
defaultTemplate :: FilePath
32+
defaultTemplate = "template.tex"
33+
34+
------------------------------------------------------------------------------
35+
-- $Library
36+
37+
-- | Display an error and exit the program
38+
errorExit :: String -> IO a
39+
errorExit msg = do
40+
putStrLn $ "error: " ++ msg
41+
exitFailure
42+
43+
------------------------------------------------------------------------------
44+
-- $Options
45+
46+
-- | Program options
47+
data Options
48+
= Options
49+
{ optTemplate :: !FilePath
50+
, optOutput :: !(Maybe FilePath)
51+
, optQueues :: !FilePath
52+
}
53+
deriving Show
54+
55+
-- | Parse program options
56+
parseOptions :: IO Options
57+
parseOptions = OA.execParser
58+
$ OA.info (LibOA.helper <*> LibOA.versioner version <*> options)
59+
$ mconcat
60+
[ OA.fullDesc
61+
, OA.progDesc "queue sheet utility"
62+
, OA.failureCode 2
63+
]
64+
where
65+
options :: OA.Parser Options
66+
options = Options
67+
<$> templateOption
68+
<*> optional outputOption
69+
<*> queuesArgument
70+
71+
templateOption :: OA.Parser FilePath
72+
templateOption = OA.strOption $ mconcat
73+
[ OA.long "template"
74+
, OA.short 't'
75+
, OA.metavar "TEMPLATE.tex"
76+
, OA.value defaultTemplate
77+
, OA.showDefaultWith id
78+
, OA.help "template file"
79+
]
80+
81+
outputOption :: OA.Parser FilePath
82+
outputOption = OA.strOption $ mconcat
83+
[ OA.long "output"
84+
, OA.short 'o'
85+
, OA.metavar "QUEUES.pdf"
86+
, OA.help "output file"
87+
]
88+
89+
queuesArgument :: OA.Parser FilePath
90+
queuesArgument = OA.strArgument $ mconcat
91+
[ OA.metavar "QUEUES.yaml"
92+
, OA.help "YAML file specifying queue information"
93+
]
94+
95+
------------------------------------------------------------------------------
96+
-- $main
97+
98+
main :: IO ()
99+
main = do
100+
Options{..} <- parseOptions
101+
either errorExit return =<< buildPdf optQueues optTemplate optOutput

doc/queue-sheet.1.md

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ hyphenate: false
1414

1515
# DESCRIPTION
1616

17-
Queue Sheet is a utility that builds PDFs of lists. The printed PDFs can be
18-
used to track progress through the queues when offline.
17+
Queue Sheet is a utility that builds PDFs of lists. Printed PDFs can be used
18+
to track progress through queues when offline.
1919

2020
# OPTIONS
2121

@@ -34,75 +34,113 @@ used to track progress through the queues when offline.
3434
# ARGUMENTS
3535

3636
*QUEUES.yaml*
37-
: YAML file specifying queue information
37+
: queue file
3838

3939
# FILES
4040

4141
## `QUEUES.yaml`
4242

43-
This file is an object with two properties.
43+
A queue is a named list of items. For example, a podcast can be represented
44+
as a queue where the queue name is the name of the podcast and each item in
45+
the queue is an episode of the podcast. Queues can optionally be organized
46+
into sections. For example, sections can be used to organize podcast queues
47+
by theme.
4448

45-
The *sections* property is a list of section names (strings). Note that the
46-
order determines the order in the output.
49+
Queues are specified in YAML format. They may be specified in a few different
50+
ways, depending on how you want to organize them.
4751

48-
The *queues* property is a list of queue objects with the following
49-
properties:
52+
To create a queue sheet of queues without sections, the YAML file consists of
53+
a list of queue objects, which have the following properties:
5054

5155
*name*
52-
: name of the queue (string, required)
56+
: queue name (string, required)
5357

5458
*url*
5559
: queue URL (string, optional)
5660

57-
*section*
58-
: name of the section (string, required)
59-
60-
*split*
61-
: *true* to display items on separate lines (boolean, default *false*)
61+
*date*
62+
: date of last update (string, optional)
6263

6364
*tags*
6465
: list of tags (list of string, optional)
6566

66-
*date*
67-
: date of last update (string, optional)
68-
6967
*prev*
70-
: previous (complete) item (item, optional)
68+
: previous item (item, optional)
7169

7270
*next*
7371
: list of next items (list of items, optional)
7472

75-
If both *prev* and *next* are specified, then *prev* is ignored.
73+
The only required property is *name*.
7674

77-
An item name may be specified using a string. To associate a URL with an
78-
item, use an object with the following properties:
75+
The *tags* property is a list of string tags that are associated with the
76+
queue. A tag must consist of at least one ASCII letter, number, period,
77+
underscore, or dash. For example, tag "complete" can be used to indicate that
78+
there will be no new episodes of a podcast that is complete.
79+
80+
The *next* property is a list of next items in the queue. When the list is
81+
exhausted, the previous item can be specified using the *prev* property. If
82+
both *prev* and *next* are specified, *prev* is ignored.
83+
84+
Items can be specified by name only, using a string or a number. To associate
85+
a URL with an item, use an object with the following properties:
7986

8087
*name*
8188
: name of the item (string, required)
8289

8390
*url*
8491
: item URL (string, optional)
8592

86-
The following tags are supported:
93+
To organize queues into sections, the YAML file should be written as an object
94+
with two properties:
8795

88-
*complete*
89-
: no new items will be added to the queue
96+
*sections*
97+
: list of sections names (optional)
9098

91-
*partial*
92-
: not all items of the source queue are added to the queue
99+
*queues*
100+
: list of queue objects (required)
101+
102+
Sections names are specified using strings. The order that the sections are
103+
listed determines the order that they are displayed on the queue sheet.
104+
105+
Queue objects are as above, with an additional property to specify the
106+
section:
107+
108+
*section*
109+
: name of the section (string, optional)
110+
111+
Queues that are not explicitly associated with a section are associated with
112+
an implicit default section.
113+
114+
To make it easier to share queue files, imports are also supported. Import
115+
another queue file using an import object instead of a queue object in a list
116+
of queues. An import object has the following properties:
117+
118+
*import*
119+
: path to the queue file to import (string, required)
120+
121+
*section*
122+
: section to associate all of the imported queues with (string, optional)
123+
124+
Paths are relative to the current file. For example, simply specify the
125+
filename of the file to import when the file is in the same directory.
126+
127+
When you specify *section*, the section must be defined in the current file.
128+
When you do not specify *section*, the sections of the imported queues are
129+
used, but they must also be defined in the current file.
93130

94131
## Template
95132

96-
A LaTeX template is used to build the PDF, using XeTeX. Unless specified
97-
otherwise, `template.tex` is used.
133+
YAML files specify the data, and templates determine how that data is
134+
displayed. A LaTeX template is used to build the PDF, using XeTeX. Unless
135+
specified otherwise, `template.tex` is used.
98136

99137
It is a Jinja2-style template using the following syntax:
100138

101139
Interpolations
102140
: `<< section.name >>`
103141

104142
Tags
105-
: `<! if queue.isSplit !>`
143+
: `<! if section.name !>`
106144

107145
Comments
108146
: `<# comment #>`
@@ -120,6 +158,9 @@ A section is an object with the following properties:
120158
*queues*
121159
: list of queues
122160

161+
Only sections that contain queues are passed to the template. The *name*
162+
property of the default section is empty.
163+
123164
A queue is an object with the following properties:
124165

125166
*name*
@@ -128,24 +169,18 @@ A queue is an object with the following properties:
128169
*url*
129170
: queue URL or empty string if no URL (string)
130171

131-
*isSplit*
132-
: *true* to display items on separate lines (boolean)
133-
134-
*isPartial*
135-
: *true* if the partial tag is set (boolean)
136-
137-
*isComplete*
138-
: *true* if the complete tag is set (boolean)
139-
140172
*date*
141173
: date or empty string if no date (string)
142174

143-
*prevItem*
175+
*prev_item*
144176
: previous item or empty string if not set (item)
145177

146-
*nextItems*
178+
*next_items*
147179
: list of next items (list of items)
148180

181+
Queue tags are exposed as boolean properties prefixed with "tag_". For
182+
example, a tag named "complete" is exposed as "tag_complete".
183+
149184
An item is an object with the following properties:
150185

151186
*name*

examples/conference-videos.pdf

31 KB
Binary file not shown.

examples/conference-videos.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
sections:
4+
- Haskell
5+
6+
queues:
7+
8+
- import: haskell-love-2020.yaml
9+
section: Haskell
10+
- import: zurihac-2020.yaml
11+
section: Haskell

examples/haskell-love-2020.pdf

27 KB
Binary file not shown.

0 commit comments

Comments
 (0)