Compare commits
4 Commits
master
...
feat/theme
| Author | SHA1 | Date |
|---|---|---|
|
|
a20451fe60 | |
|
|
7e138615b7 | |
|
|
90aba43e1e | |
|
|
131443b7c5 |
|
|
@ -0,0 +1,259 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
"title": "Document Theme Component System",
|
||||||
|
"description": "A schema for a theme that defines reusable components and their layout.",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"header": { "$ref": "#/$defs/headerObject" },
|
||||||
|
"settings": { "$ref": "#/$defs/settingsObject" },
|
||||||
|
"content": { "$ref": "#/$defs/contentRootObject" }
|
||||||
|
},
|
||||||
|
"required": ["header", "settings", "content"],
|
||||||
|
"$defs": {
|
||||||
|
"headerObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": { "theme": { "$ref": "#/$defs/themeObject" } },
|
||||||
|
"required": ["theme"]
|
||||||
|
},
|
||||||
|
"themeObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": { "type": "string" },
|
||||||
|
"author": { "type": "string" },
|
||||||
|
"version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" }
|
||||||
|
},
|
||||||
|
"required": ["name", "author", "version"]
|
||||||
|
},
|
||||||
|
"settingsObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"page size": { "type": "string", "enum": ["A4", "A5", "Letter", "Legal"] },
|
||||||
|
"margin": { "$ref": "#/$defs/marginObject" }
|
||||||
|
},
|
||||||
|
"required": ["page size"]
|
||||||
|
},
|
||||||
|
"contentRootObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"settings": { "$ref": "#/$defs/contentSettingsObject" },
|
||||||
|
"cover": { "$ref": "#/$defs/pageSection" },
|
||||||
|
"backcover": { "$ref": "#/$defs/pageSection" },
|
||||||
|
"interior": { "$ref": "#/$defs/pageSection" }
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
"contentSettingsObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"definitions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "#/$defs/definitionObject" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["definitions"]
|
||||||
|
},
|
||||||
|
"definitionObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"class": { "type": "string" },
|
||||||
|
"content": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "#/$defs/componentItem" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["class", "content"]
|
||||||
|
},
|
||||||
|
"pageSection": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"settings": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"paper color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
|
||||||
|
"margin": { "$ref": "#/$defs/marginObject" }
|
||||||
|
},
|
||||||
|
"required": ["paper color"]
|
||||||
|
},
|
||||||
|
"contents": { "type": "array", "items": { "$ref": "#/$defs/contentItem" } }
|
||||||
|
},
|
||||||
|
"required": ["settings", "contents"]
|
||||||
|
},
|
||||||
|
"marginObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"top": { "$ref": "#/$defs/measurementObject" },
|
||||||
|
"bottom": { "$ref": "#/$defs/measurementObject" },
|
||||||
|
"left": { "$ref": "#/$defs/measurementObject" },
|
||||||
|
"right": { "$ref": "#/$defs/measurementObject" }
|
||||||
|
},
|
||||||
|
"required": ["top", "bottom", "left", "right"]
|
||||||
|
},
|
||||||
|
"measurementObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"value": { "type": "number" },
|
||||||
|
"unit": { "type": "string", "enum": ["cm", "mm", "in", "pt", "px"] }
|
||||||
|
},
|
||||||
|
"required": ["value", "unit"]
|
||||||
|
},
|
||||||
|
"contentItem": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "An item with absolute position on a page.",
|
||||||
|
"properties": {
|
||||||
|
"coordinates": { "$ref": "#/$defs/coordinatesObject" },
|
||||||
|
"information": { "$ref": "#/$defs/informationUnion" }
|
||||||
|
},
|
||||||
|
"required": ["coordinates", "information"]
|
||||||
|
},
|
||||||
|
"componentItem": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "An item within a component definition, without absolute coordinates.",
|
||||||
|
"properties": {
|
||||||
|
"information": { "$ref": "#/$defs/informationUnion" }
|
||||||
|
},
|
||||||
|
"required": ["information"]
|
||||||
|
},
|
||||||
|
"informationUnion": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "$ref": "#/$defs/drawingInformation" },
|
||||||
|
{ "$ref": "#/$defs/textInformation" },
|
||||||
|
{ "$ref": "#/$defs/documentBodyInformation" },
|
||||||
|
{ "$ref": "#/$defs/imageInformation" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"coordinatesObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"x": { "$ref": "#/$defs/positionRange" },
|
||||||
|
"y": { "$ref": "#/$defs/positionRange" },
|
||||||
|
"layer": { "type": "integer" }
|
||||||
|
},
|
||||||
|
"required": ["x", "y", "layer"]
|
||||||
|
},
|
||||||
|
"positionRange": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"start": { "type": "number" },
|
||||||
|
"end": { "type": "number" }
|
||||||
|
},
|
||||||
|
"required": ["start"]
|
||||||
|
},
|
||||||
|
"drawingInformation": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": { "const": "drawing" },
|
||||||
|
"dimension": { "$ref": "#/$defs/dimensionObject" },
|
||||||
|
"relative position": { "$ref": "#/$defs/relativePositionObject" },
|
||||||
|
"rotation": { "type": "number" },
|
||||||
|
"shape": {
|
||||||
|
"oneOf": [
|
||||||
|
{ "$ref": "#/$defs/rectangleShape" },
|
||||||
|
{ "$ref": "#/$defs/lineShape" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"line": { "$ref": "#/$defs/lineObject" },
|
||||||
|
"fill": { "$ref": "#/$defs/fillObject" },
|
||||||
|
"settings": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"padding": { "$ref": "#/$defs/marginObject" },
|
||||||
|
"skip margin": { "type": "boolean" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["type", "shape"]
|
||||||
|
},
|
||||||
|
"textInformation": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": { "const": "text" },
|
||||||
|
"font": { "$ref": "#/$defs/fontObject" },
|
||||||
|
"variable": { "type": "string", "pattern": "^\\$.+" }
|
||||||
|
},
|
||||||
|
"required": ["type", "font", "variable"]
|
||||||
|
},
|
||||||
|
"documentBodyInformation": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": { "const": "document body" },
|
||||||
|
"font": { "$ref": "#/$defs/fontObject" },
|
||||||
|
"variable": { "type": "string", "pattern": "^\\$.+" }
|
||||||
|
},
|
||||||
|
"required": ["type", "font", "variable"]
|
||||||
|
},
|
||||||
|
"imageInformation": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": { "const": "image" },
|
||||||
|
"dimension": { "$ref": "#/$defs/dimensionObject" },
|
||||||
|
"relative position": { "$ref": "#/$defs/relativePositionObject" }
|
||||||
|
},
|
||||||
|
"required": ["type", "dimension"]
|
||||||
|
},
|
||||||
|
"dimensionObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"width": { "$ref": "#/$defs/measurementObject" },
|
||||||
|
"height": { "$ref": "#/$defs/measurementObject" },
|
||||||
|
"layer": { "type": "integer" }
|
||||||
|
},
|
||||||
|
"required": ["width", "height", "layer"]
|
||||||
|
},
|
||||||
|
"relativePositionObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"horizontal": { "type": "string", "enum": ["left", "center", "right"] },
|
||||||
|
"vertical": { "type": "string", "enum": ["top", "center", "bottom"] }
|
||||||
|
},
|
||||||
|
"required": ["horizontal", "vertical"]
|
||||||
|
},
|
||||||
|
"fontObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"size": { "type": "number" },
|
||||||
|
"name": { "type": "string" }
|
||||||
|
},
|
||||||
|
"required": ["size", "name"]
|
||||||
|
},
|
||||||
|
"rectangleShape": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"type": { "const": "rectangle" },
|
||||||
|
"corner radius": { "$ref": "#/$defs/cornerRadiusObject" }
|
||||||
|
},
|
||||||
|
"required": ["type"]
|
||||||
|
},
|
||||||
|
"lineShape": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": { "type": { "const": "line" } },
|
||||||
|
"required": ["type"]
|
||||||
|
},
|
||||||
|
"cornerRadiusObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"top left": { "type": "number" },
|
||||||
|
"top right": { "type": "number" },
|
||||||
|
"bottom left": { "type": "number" },
|
||||||
|
"bottom right": { "type": "number" }
|
||||||
|
},
|
||||||
|
"required": ["top left", "top right", "bottom left", "bottom right"]
|
||||||
|
},
|
||||||
|
"lineObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"stroke": { "type": "string", "enum": ["solid", "dashed", "dotted"] },
|
||||||
|
"width": { "type": "number" },
|
||||||
|
"color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" }
|
||||||
|
},
|
||||||
|
"required": ["stroke", "width", "color"]
|
||||||
|
},
|
||||||
|
"fillObject": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
|
||||||
|
"opacity": { "type": "number", "minimum": 0, "maximum": 1 }
|
||||||
|
},
|
||||||
|
"required": ["color"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,266 @@
|
||||||
|
{
|
||||||
|
"header": {
|
||||||
|
"theme": {
|
||||||
|
"name": "Bee",
|
||||||
|
"author": "Gustavo Henrique Miranda",
|
||||||
|
"version": "0.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"page size": "A5",
|
||||||
|
"margin": {
|
||||||
|
"top": {
|
||||||
|
"value": 3,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"bottom": {
|
||||||
|
"value": 3,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"value": 5,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"settings": {
|
||||||
|
"definitions": [
|
||||||
|
{
|
||||||
|
"class": "photo",
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"information": {
|
||||||
|
"type": "drawing",
|
||||||
|
"shape": {
|
||||||
|
"type": "rectangle"
|
||||||
|
},
|
||||||
|
"dimension": {
|
||||||
|
"width": {
|
||||||
|
"value": 88,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"height": {
|
||||||
|
"value": 107,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"layer": 0
|
||||||
|
},
|
||||||
|
"line": {
|
||||||
|
"stroke": "solid",
|
||||||
|
"width": 0,
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
},
|
||||||
|
"fill": {
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"padding": {
|
||||||
|
"top": {
|
||||||
|
"value": 4.5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"bottom": {
|
||||||
|
"value": 23.5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"value": 4.5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"value": 4.5,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"information": {
|
||||||
|
"type": "image",
|
||||||
|
"dimension": {
|
||||||
|
"width": {
|
||||||
|
"value": 79,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"height": {
|
||||||
|
"value": 79,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"layer": 1
|
||||||
|
},
|
||||||
|
"relative position": {
|
||||||
|
"horizontal": "center",
|
||||||
|
"vertical": "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"cover": {
|
||||||
|
"settings": {
|
||||||
|
"paper color": "#000000",
|
||||||
|
"margin": {
|
||||||
|
"top": {
|
||||||
|
"value": 0,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"bottom": {
|
||||||
|
"value": 0,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"left": {
|
||||||
|
"value": 0,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"value": 0,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contents": [
|
||||||
|
{
|
||||||
|
"coordinates": {
|
||||||
|
"x": {
|
||||||
|
"start": 74,
|
||||||
|
"end": 148
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"start": 105,
|
||||||
|
"end": 210
|
||||||
|
},
|
||||||
|
"layer": 0
|
||||||
|
},
|
||||||
|
"information": {
|
||||||
|
"type": "drawing",
|
||||||
|
"shape": {
|
||||||
|
"type": "rectangle",
|
||||||
|
"corner radius": {
|
||||||
|
"top left": 5,
|
||||||
|
"top right": 5,
|
||||||
|
"bottom left": 5,
|
||||||
|
"bottom right": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"line": {
|
||||||
|
"stroke": "solid",
|
||||||
|
"width": 0.1,
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
},
|
||||||
|
"fill": {
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"coordinates": {
|
||||||
|
"x": {
|
||||||
|
"start": 74
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"start": 105
|
||||||
|
},
|
||||||
|
"layer": 1
|
||||||
|
},
|
||||||
|
"information": {
|
||||||
|
"type": "text",
|
||||||
|
"font": {
|
||||||
|
"size": 24,
|
||||||
|
"name": "arial"
|
||||||
|
},
|
||||||
|
"variable": "$diaryName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"backcover": {
|
||||||
|
"settings": {
|
||||||
|
"paper color": "#000000"
|
||||||
|
},
|
||||||
|
"contents": []
|
||||||
|
},
|
||||||
|
"interior": {
|
||||||
|
"settings": {
|
||||||
|
"paper color": "#F1E9D2"
|
||||||
|
},
|
||||||
|
"contents": [
|
||||||
|
{
|
||||||
|
"coordinates": {
|
||||||
|
"x": {
|
||||||
|
"start": 0
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"start": 0
|
||||||
|
},
|
||||||
|
"layer": 1
|
||||||
|
},
|
||||||
|
"information": {
|
||||||
|
"type": "text",
|
||||||
|
"font": {
|
||||||
|
"size": 15,
|
||||||
|
"name": "arial"
|
||||||
|
},
|
||||||
|
"variable": "$entryTitle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"coordinates": {
|
||||||
|
"x": {
|
||||||
|
"start": 0,
|
||||||
|
"end": 148
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"start": 15,
|
||||||
|
"end": 210
|
||||||
|
},
|
||||||
|
"layer": 0
|
||||||
|
},
|
||||||
|
"information": {
|
||||||
|
"type": "drawing",
|
||||||
|
"shape": {
|
||||||
|
"type": "line"
|
||||||
|
},
|
||||||
|
"line": {
|
||||||
|
"stroke": "solid",
|
||||||
|
"width": 0.1,
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
},
|
||||||
|
"fill": {
|
||||||
|
"color": "#FFFFFF"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"skip margin": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"coordinates": {
|
||||||
|
"x": {
|
||||||
|
"start": 0
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"start": 0
|
||||||
|
},
|
||||||
|
"layer": 1
|
||||||
|
},
|
||||||
|
"information": {
|
||||||
|
"type": "document body",
|
||||||
|
"font": {
|
||||||
|
"size": 12,
|
||||||
|
"name": "arial"
|
||||||
|
},
|
||||||
|
"variable": "$entryContent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,4 +25,4 @@ Homepage = "https://github.com/gmbrax/Pilgrim/"
|
||||||
Issues = "https://github.com/gmbrax/Pilgrim/issues"
|
Issues = "https://github.com/gmbrax/Pilgrim/issues"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
pilgrim = "epstein.command:main"
|
epstein = "epstein.command:main"
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class Application:
|
||||||
|
def __init__(self):
|
||||||
|
self.args = self.__setup_args
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __setup_args(self):
|
||||||
|
parser = argparse.ArgumentParser(prog="epstein",
|
||||||
|
description='Test for PDF Export Module for pilgrim')
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers(dest="command",required=True)
|
||||||
|
print_parser = subparsers.add_parser("print", help="generate the PDF file ")
|
||||||
|
print_parser.add_argument("-t", "--theme", required=True, help="Define the theme to use.")
|
||||||
|
print_parser.set_defaults(func=self.handle_print)
|
||||||
|
|
||||||
|
|
||||||
|
theme_parser = subparsers.add_parser("theme", help="Manage the themes")
|
||||||
|
theme_subparsers = theme_parser.add_subparsers(dest="theme_action", help="Actions for the themes" , required=True)
|
||||||
|
|
||||||
|
theme_create_parser = theme_subparsers.add_parser("create", help="Create a new theme")
|
||||||
|
theme_create_parser.add_argument("-n", "--name", required=True, help="Name of the theme")
|
||||||
|
theme_create_parser.set_defaults(func=self.handle_theme_create)
|
||||||
|
|
||||||
|
theme_list_parser = theme_subparsers.add_parser("list", help="List all the themes")
|
||||||
|
theme_list_parser.set_defaults(func=self.handle_theme_list)
|
||||||
|
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1] == 'theme':
|
||||||
|
theme_parser.print_help(sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
parser.print_help(sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def handle_print(self):
|
||||||
|
print("handle print")
|
||||||
|
|
||||||
|
def handle_theme_create(self):
|
||||||
|
print("handle theme create")
|
||||||
|
|
||||||
|
def handle_theme_list(self):
|
||||||
|
print("handle theme list")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.args.func()
|
||||||
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
from epstein.application import *
|
import argparse
|
||||||
|
|
||||||
|
from epstein.application import Application
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("hello world")
|
print("hello world")
|
||||||
|
app = Application()
|
||||||
|
app.run()
|
||||||
|
|
||||||
if __name__ =="__main__":
|
if __name__ =="__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue