tinyssg 0.0.11__py3-none-any.whl → 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tinyssg/__init__.py CHANGED
@@ -548,7 +548,7 @@ class TinySSGLauncher:
548
548
  newargv = args.copy()
549
549
  newargv['mode'] = servcommand
550
550
 
551
- command = [sys.executable, __file__, '--config', f"{json.dumps(newargv)}", 'config']
551
+ command = [sys.executable, '-m', 'tinyssg', '--config', f"{json.dumps(newargv)}", 'config']
552
552
 
553
553
  process = subprocess.Popen(
554
554
  command,
@@ -694,17 +694,17 @@ class TinySSG:
694
694
  """
695
695
  parser = argparse.ArgumentParser(prog='python -m tinyssg', description='TinySSG Simple Static Site Generate Tool')
696
696
  parser.add_argument('mode', choices=['dev', 'gen', 'cls', 'serv', 'servreload', 'config'], help='Select the mode to run (gen = Generate HTML files, dev = Run the debug server)')
697
- parser.add_argument('--port', '-P', type=int, default=8000, help='Port number for the debug server')
698
697
  parser.add_argument('--page', '-p', type=str, default='pages', help='Page file path')
699
698
  parser.add_argument('--static', '-s', type=str, default='static', help='Static file path')
700
699
  parser.add_argument('--lib', '-l', type=str, default='libs', help='Library file path')
701
- parser.add_argument('--input', '-i', type=str, default='', help='Input file name (Used to generate specific files only)')
702
700
  parser.add_argument('--output', '-o', type=str, default='dist', help='Output directory path')
701
+ parser.add_argument('--input', '-i', type=str, default='', help='Input file name (Used to generate specific files only)')
702
+ parser.add_argument('--curdir', '-C', type=str, default='', help='Current directory')
703
+ parser.add_argument('--port', '-P', type=int, default=8000, help='Port number for the debug server')
703
704
  parser.add_argument('--wait', '-w', type=int, default=5, help='Wait time for file change detection')
704
705
  parser.add_argument('--nolog', '-n', action='store_true', help='Do not output debug server log')
705
706
  parser.add_argument('--noreload', '-r', action='store_true', help='Do not reload the server when the file changes')
706
707
  parser.add_argument('--noopen', '-N', action='store_true', help='Do not open the browser when starting the server')
707
- parser.add_argument('--curdir', '-C', type=str, default='', help='Current directory (For Jupyter)')
708
708
  parser.add_argument('--config', '-c', type=str, default='', help='Configuration json string')
709
709
  parser.add_argument('--jwidth', '-jw', type=str, default='600', help='Jupyter iframe width')
710
710
  parser.add_argument('--jheight', '-jh', type=str, default='600', help='Jupyter iframe height')
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.2
2
+ Name: tinyssg
3
+ Version: 1.0.0
4
+ Summary: A simple static site generator
5
+ Author: Uniras
6
+ Author-email: tkappeng@gmail.com
7
+ License: MIT License
8
+ Project-URL: Homepage, https://github.com/uniras/tinyssg
9
+ Project-URL: Repository, https://github.com/uniras/tinyssg
10
+ Keywords: ssg,static site generator,html
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3 :: Only
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Topic :: Utilities
26
+ Description-Content-Type: text/markdown
27
+
28
+ # TinySSG
29
+
30
+ ## Overview
31
+
32
+ TinySSG is a simple static site generator with file-based routing.
33
+ It combines simplicity and flexibility by writing pages in Python code with a simple structure.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install tinyssg
39
+ ````
40
+
41
+ ## Usage
42
+
43
+ ### directory structure
44
+
45
+ Configure the directory as follows.The directory name can be changed with an optional argument.
46
+
47
+ ```text
48
+ |-- pages Place Python files for SSG deployment.
49
+ |-- libs Place Python files that are not SSG target files (e.g. libraries).
50
+ |-- static Place static files that are not subject to SSG (css, images, etc.)
51
+ |-- dist This is the directory where SSG results will be output.The contents of this directory can be published as a web site by placing it on a web server.
52
+ |-- static The static directory is copied to this directory.
53
+ ````
54
+
55
+ ### Creating pages
56
+
57
+ Create a Python file in the `pages` directory and create a class that extends the `TinySSGPage` class.
58
+
59
+ ```python
60
+ from tinyssg import TinySSGPage
61
+
62
+ class IndexPage(TinySSGPage):.
63
+ def query(self):.
64
+ return {
65
+ 'title': 'Index', 'content': 'Hello, World!
66
+ 'content': 'Hello, World!'
67
+ }
68
+
69
+ def template(self): return
70
+ return '''
71
+ <!DOCTYPE html>
72
+ <html>
73
+ <head>
74
+ <meta charset="utf-8" />
75
+ <title>{{ title }}</title>
76
+ </head>
77
+ <body>
78
+ <h1>{{ title }}</h1>
79
+ <p>{{ content }}</p>
80
+ </body>
81
+ </html>'''
82
+ ```
83
+
84
+ Building it will generate an HTML file with the same name as the Python file.
85
+ If multiple `TinySSGPage` inherited classes are defined in the Python file, the Python file name becomes the folder name and the class name in it becomes the HTML file name.
86
+
87
+ The `query` method returns the data to be passed to the template, and the `template` method returns the HTML template.
88
+ TinySSG uses the return values of these methods to generate HTML.
89
+
90
+ The data returned by the `query` method must be in Python dictionary format or Python dictionary list format.
91
+ In the case of dictionary format, an HTML file is generated with the python filename or class name, and in the case of list format, a directory is created equal to the python filename or class name, and by default, an HTML file is generated with a filename of .html, a number from 1.
92
+ If a string representing a key name is returned with the list as a tuple on `return`, an HTML file is generated with the value corresponding to the key as the file name.
93
+
94
+ By default, `TinySSG` simply replaces the parts of the template enclosed in `{{ key name }}` with the value corresponding to the key in the dictionary that is the return value of the `query` method,
95
+ You can also override the `render` method for more complex processing, or use a template engine such as Jinja2.
96
+
97
+ You can also define a process to convert the rendered text to final HTML by overriding the `translate` method.
98
+ If you use the markdown library here to describe the process of conversion, you can write the template in Markdown instead of HTML.
99
+
100
+ Each page must be defined individually, but since this is a simple Python class, if you want to apply it to multiple pages, you can create a class that defines the common parts and inherit it to easily apply it without copying any code.
101
+
102
+ ### Start local server for development.
103
+
104
+ ```bash
105
+ python -m tinyssg dev
106
+ ```
107
+
108
+ The local server for development will be started.You can see the generated HTML by accessing ``http://localhost:8000``.
109
+
110
+ If you change files in the `pages`, `libs`, or `static` directories, the server will automatically restart to reflect the changes.
111
+
112
+ ### Generating HTML
113
+
114
+ ```bash
115
+ python -m tinyssg gen
116
+ ```
117
+
118
+ HTML files will be generated in the `dist` directory.
119
+
120
+ ### options (excerpt)
121
+
122
+ ```text
123
+
124
+ usage: python -m tinyssg [--page PAGE] [--static STATIC] [--lib LIB] [--input INPUT] [--output OUTPUT] [--port PORT] [--wait WAIT] [--nolog] [--noreloadnoreload] [--noopen] [--curdir CURDIR] [mode]
125
+
126
+ MODE:
127
+
128
+ Specifies startup mode (gen = generate HTML files, dev = start local server for development).
129
+
130
+ Options:
131
+ --page PAGE, -p PAGE Directory for page files
132
+ --static STATIC, -s STATIC Directory for static files
133
+ --lib LIB, -l LIB Directory for library files
134
+ --output OUTPUT, -o OUTPUT Specify output directory.
135
+ --input INPUT, -i INPUT Specifies which files to include in SSG (if not specified, all files in the directory are included).
136
+ --port PORT, -P PORT Specify the port number of the development server.
137
+ --wait WAIT, -w WAIT Wait time to prevent multiple restarts.
138
+ --nolog, -n Do not output request log to development server
139
+ --noreload, -r Don't restart development server automatically.
140
+ --noopen, -N Do not open browser when starting development server
141
+ --curdir CURDIR, -C CURDIR Specify current directory.
142
+ ```
@@ -0,0 +1,6 @@
1
+ tinyssg/__init__.py,sha256=IX78iWBhjKJj1psk2wjqTh5HDUU3kTNd5licWpKY3cs,27408
2
+ tinyssg/__main__.py,sha256=E8PEZ-wWYae76H_iWbY1Xu9VYGb6sfsWMN-hzqTMoBc,83
3
+ tinyssg-1.0.0.dist-info/METADATA,sha256=gIWDqy6ZUA9tAZnfKvJ38ul9UbvjYBC8DaP0wNNbmWk,6039
4
+ tinyssg-1.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ tinyssg-1.0.0.dist-info/top_level.txt,sha256=8u1XtPYCatbklb6u3NbJbFUbwA8nDKZ6cY3FScGwJDQ,8
6
+ tinyssg-1.0.0.dist-info/RECORD,,
@@ -1,106 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: tinyssg
3
- Version: 0.0.11
4
- Summary: A simple static site generator
5
- Author: Uniras
6
- Author-email: tkappeng@gmail.com
7
- License: MIT License
8
- Project-URL: Homepage, https://github.com/uniras/tinyssg
9
- Project-URL: Repository, https://github.com/uniras/tinyssg
10
- Keywords: ssg,static site generator,html
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.7
16
- Classifier: Programming Language :: Python :: 3.8
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Programming Language :: Python :: 3.13
22
- Classifier: Programming Language :: Python :: 3 :: Only
23
- Classifier: Topic :: Software Development :: Libraries
24
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
- Classifier: Topic :: Utilities
26
- Description-Content-Type: text/markdown
27
-
28
- # TinySSG
29
-
30
- ## 概要
31
-
32
- TinySSGは、ファイルベースルーティングのシンプルな静的サイトジェネレータです。
33
- ページを簡単な構造のTinySSGPageクラスを継承したPythonコードで記述することで単純さと柔軟性を両立しています。
34
-
35
- ## インストール
36
-
37
- ```bash
38
- pip install tinyssg
39
- ```
40
-
41
- ## 使い方
42
-
43
- ### ディレクトリ構成
44
-
45
- 以下のようにディレクトリを構成します。ディレクトリ名はオプション引数で変更可能です。
46
-
47
- ```text
48
- --- proect
49
- |-- pages SSGの対象となるPythonファイルを配置します
50
- |-- libs SSG・デプロイの対象にならないPythonファイルを配置します(ライブラリなど)
51
- |-- static SSGの対象にならない静的ファイルを配置します(css, 画像など)
52
- |-- dist SSGの結果が出力されるディレクトリです。このディレクトリの中身をWebサーバに配置することでWebサイトとして公開できます。
53
- |-- static staticディレクトリはこのディレクトリにコピーされます
54
- ```
55
-
56
- pages, libs, staticディレクトリは、開発サーバー起動時に監視され、ファイルが変更されると自動的にサーバーを再起動します。
57
-
58
- ### ページの作成
59
-
60
- `Page`ディレクトリ内にPythonファイルを作り、`TinySSGPage`クラスを継承したクラスを作成します。
61
-
62
- ```python
63
- from tinyssg import TinySSGPage
64
-
65
- class IndexPage(TinySSGPage):
66
- def query(self):
67
- return {
68
- 'title': 'Index',
69
- 'content': 'Hello, World!'
70
- }
71
-
72
- def template(self):
73
- return '''
74
- <!DOCTYPE html>
75
- <html>
76
- <head>
77
- <meta charset="utf-8" />
78
- <title>{{ title }}</title>
79
- </head>
80
- <body>
81
- <h1>{{ title }}</h1>
82
- <p>{{ content }}</p>
83
- </body>
84
- </html>'''
85
- ```
86
-
87
- `query`メソッドでテンプレートに渡すデータを返し、`template`メソッドでHTMLテンプレートを返します。
88
- TinySSGは、これらのメソッドの返り値を使ってHTMLを生成します。
89
-
90
- `query`メソッドが返すデータは、Python辞書形式またはPython辞書のリスト形式である必要があります。
91
- 辞書形式の場合はpythonファイル名のHTMLファイルが生成され、リスト形式の場合はPythonファイル名と同じディレクトリが作成され、デフォルトでは1からの数字.htmlのファイル名でHTMLファイルが生成されます。
92
- `return`の際にタプルとしてリストと一緒にキー名を表す文字列を返すと、そのキーに対応する値をファイル名としてHTMLファイルが生成されます。
93
-
94
- `TinySSG`はデフォルトでは単純にテンプレートの`{{ キー名 }}`で囲まれた部分を`query`メソッドの返り値である辞書のキーに対応する値で単純に置換するだけですが、
95
- `render`メソッドをオーバーライドすることで、より複雑な処理を行うこともできます。Jinja2などのテンプレートエンジンを使うこともできます。
96
-
97
- また、`translate`メソッドをオーバーライドすることで、レンダー後のテキストを最終的なHTMLに変換する処理を定義することもできます。
98
- ここでmarkdownライブラリを使って変換する処理を記述すればテンプレートをHTMLではなくMarkdownで記述することができます。
99
-
100
- それぞれページごとに定義することになりますが、単純なPythonクラスですので複数のページに適用したい場合は共通部分を定義したクラスを作成し、それを継承することでコードをコピーすることなく簡単に適用することができます。
101
-
102
- ### HTMLの生成
103
-
104
- ```bash
105
- python -m tinyssg gen
106
- ```
@@ -1,6 +0,0 @@
1
- tinyssg/__init__.py,sha256=uaCHaXdBRlKRWy4sdsPLIn738hEqQfWkxF7KUjUmon0,27415
2
- tinyssg/__main__.py,sha256=E8PEZ-wWYae76H_iWbY1Xu9VYGb6sfsWMN-hzqTMoBc,83
3
- tinyssg-0.0.11.dist-info/METADATA,sha256=L-Ggr4WRH7krJLrADUSuI5jYjb-fzDr6Irqnm82nCjo,5069
4
- tinyssg-0.0.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
- tinyssg-0.0.11.dist-info/top_level.txt,sha256=8u1XtPYCatbklb6u3NbJbFUbwA8nDKZ6cY3FScGwJDQ,8
6
- tinyssg-0.0.11.dist-info/RECORD,,