Skip to content

Commit

Permalink
Options
Browse files Browse the repository at this point in the history
  • Loading branch information
kompoth committed Apr 1, 2024
1 parent 529e392 commit a6821b5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 30 deletions.
11 changes: 9 additions & 2 deletions muckraker/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, field_validator
from typing import Optional, Literal

MAX_BODY_LEN = 6000
Expand All @@ -14,10 +14,17 @@ class IssueHeading(BaseModel):


class IssueConfig(BaseModel):
bg: Optional[Literal["bashcorpo_v5", "bashcorpo_v5_pale"]] = None
bg: Optional[Literal["none", "bashcorpo_v5", "bashcorpo_v5_pale"]] = None
size: Optional[Literal["a4", "a5", "demitab"]] = "a4"
heading: IssueHeading

@field_validator("bg")
@classmethod
def set_to_none(cls, value):
if value == "none":
return None
return value


class Issue(BaseModel):
config: IssueConfig
Expand Down
52 changes: 37 additions & 15 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,48 @@ <h2>Issue creation</h2>
<p>Configure your gazette, compose articles and push <em>Send to print</em> to generate a PDF.</p>
<p>See a sample issue screenshot <a href="https://raw.githubusercontent.com/kompoth/muckraker/main/media/issue.jpg">here</a>.</p>
<form>
<label for="heading-input">Heading:</label>
<input type="text" maxlength="50" id="heading-input" name="heading"/>
<label for="subheading-input">Subheading:</label>
<input type="text" maxlength="50" id="subheading-input" name="subheading"/>
<label for="issue-no-input">Issue number:</label>
<input type="text" maxlength="50" id="issue-no-input" name="issue-no"/>
<label for="issue-date-input">Issue date:</label>
<input type="text" maxlength="50" id="issue-date-input" name="issue-date"/>
<label for="issue-cost-input">Cost:</label>
<input type="text" maxlength="50" id="issue-cost-input" name="issue-cost"/>
<fieldset>
<legend>Heading</legend>
<label for="title-input">Title:</label>
<input type="text" maxlength="50" id="title-input" name="title"/>
<label for="subtitle-input">Subtitle:</label>
<input type="text" maxlength="50" id="subtitle-input" name="subtitle"/>
<label for="issue-no-input">Issue number:</label>
<input type="text" maxlength="50" id="issue-no-input" name="issue-no"/>
<label for="issue-date-input">Issue date:</label>
<input type="text" maxlength="50" id="issue-date-input" name="issue-date"/>
<label for="issue-cost-input">Cost:</label>
<input type="text" maxlength="50" id="issue-cost-input" name="issue-cost"/>
</fieldset>

<label for="issue-body-textarea">Issue body (<span id="body-length-tracker">0</span>):</label>
<textarea id="issue-body-textarea" name="issue-body" rows=10 maxlength="6000" onkeyup="trackBodyLenght();" placeholder="See syntax cheatsheet below"></textarea>
<fieldset>
<legend>Issue body (<span id="body-length-tracker">0</span>)</legend>
<textarea id="issue-body-textarea" name="issue-body" rows=10 maxlength="6000" onkeyup="trackBodyLenght();" placeholder="See syntax cheatsheet below"></textarea>
</fieldset>

<!--fieldset>
<legend>Attached files</legend>
<ul id="attached-images-list">
</ul>
<ul id="attached-images-list"></ul>
<input type="file" id="image-input" multiple accept="image/png,image/jpg,image/jpeg" onchange="updateImageList();"/>
</fieldset-->

<fieldset>
<legend>Options</legend>
<label for="size-select">Size:
<select id="size-select" name="size">
<option value="a4">A4 (210 x 297 mm)</option>
<option value="a5">A5 (148 x 210 mm)</option>
<option value="demitab">Demitab (200 x 270 mm)</option>
</select>
</label>
<label for="bg-select">Paper texture:
<select id="bg-select" name="bg">
<option value="bashcorpo_v5">Grungy</option>
<option value="bashcorpo_v5_pale">Grungy pale</option>
<option value="none">None</option>
</select>
</label>
</fieldset>
<input type="file" id="image-input" multiple accept="image/png,image/jpg,image/jpeg" onchange="updateImageList();" disabled/-->

<button id="print-button" type="button" onclick="requestPDF();">Send to print</button>
</form>
Expand Down
10 changes: 5 additions & 5 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ function updateImageList () {

async function requestPDF() {
document.getElementById("print-button").disabled = true;

const requestBody = {
config: {
bg: "bashcorpo_v5_pale",
size: "demitab",
size: document.getElementById("size-select").value,
bg: document.getElementById("bg-select").value,
heading: {
title: document.getElementById("heading-input").value,
subtitle: document.getElementById("subheading-input").value,
title: document.getElementById("title-input").value,
subtitle: document.getElementById("subtitle-input").value,
no: document.getElementById("issue-no-input").value,
date: document.getElementById("issue-date-input").value,
cost: document.getElementById("issue-cost-input").value
Expand Down
8 changes: 0 additions & 8 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ header p {
font-family: TT2020, monospace;
font-weight: normal;
}
#issue-body-textarea {
background-color: var(--bg);
color: var(--fg);
border: 1px solid var(--fg);
}
#issue-body-textarea:focus {
border: 2px solid var(--fg);
}

/* File loading button */
input[type=file]::file-selector-button {
Expand Down

0 comments on commit a6821b5

Please sign in to comment.