An amazing web prototyping tool.
Project description
Clay
An amazing prototyping tool.
With Clay you can forget about making changes to dozens of HTML files just because you need to add a link in the footer.
You can also use it to prototype your AJAX-driven application or the responses of sending forms, because it acts like a real server.
Install
pip install clay
Clay version 3.x only works with Python 3.6, 3.7, and 3.8.
Quickstart
clay new myapp
will generate a new app container with the following structure:
myapp
├── static/
├── clay.yaml
└── ...other files
You can also use an optional project template path or git URL. For the URLs, "gh:" works as a shortcut of "https://github.com/" and "gl:" as a shortcut of "https://gitlab.com/". For example:
# Absolute or relative path.
clay new myapp /path/to/project/template
# GitHub repo. Note the ".git" postfix.
clay new myapp https://github.com/lucuma/clay-template.git
# The same GitHub repo with shortcut
clay new myapp gh:/lucuma/clay-template.git
Development server
Inside that folder, run the development server with:
clay run
and your site'll be available at http://0.0.0.0:8080/.
Anything inside the static folder is served as-is under the /static/ path.
For example you can see myapp/static/image.png at the http://0.0.0.0:8080/static/image.png URL.
Any file outside the static folder, is rendered as a page.
For example, myapp/page.html is rendered and shown at http://0.0.0.0:8080/page.html, as an HTML page.
And myapp/foo/bar.json is rendered and shown at http://0.0.0.0:8080/foo/bar.json as a JSON document.
Remember to put inside static anything you don't want to be rendered.
Build version
To generate a static version of your site, first, stop the server with
Control + C, and then run:
clay build
and all the templates will be processed and the result stored inside the
build folder.
Static files
If you have folders in your project, you might be tempted to write internal URLs like this
<!-- DON'T DO THIS ->
href="../a.html"
src="../static/main.js"
Don't do it. Is error-prone and could not worl if you do it in a base layout, for example. Always write the internal URLs using their path from the root of the project, like this:
href="/a.html"
src="/static/main.js"
That'll work on the development server and also when generating a static version of your site, Clay will convert them into relative paths automatically.
Template globals
When writing your templates, in addition of what is normally available in Jinja templates you have access to some other helper functions:
- The python's functions
dir,enumerate,map,zip, andlen. - The
nowfunction, as an alias todatetime.datetime.utcnow. - The
activefunction, to set an "active" class in navigations/menus when the current page match.
active()
active(*url_patterns, partial=False, class_name="active")
TODO
The clay.yaml file
If a YAML file named clay.yaml is found in the root of the project, it will be read and used for configuring Clay.
# Shell-style patterns files/folders that must not be rendered.
exclude:
- ".*"
- ".*/*"
- "_*"
- "_*/*"
- "*.txt"
# Shell-style patterns files/folders that *must be* rendered, even if
# they are in the exclude list
include:
- "robots.txt"
- "humans.txt"
Update from v2 to v3+
Before v3, previous versions of Clay did work with having all source files in a source subfolder. However, this is no longer the case, and the recommended setup is to have them in the parent folder instead.
The old project with a source folder still works, but it might change in future versions.
Happy coding!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clay-3.0.2.tar.gz.
File metadata
- Download URL: clay-3.0.2.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc1b7b182f0a6326263d72d0da7e970ff41bfc8aee87b9517a096e43169a3c02
|
|
| MD5 |
a12efc833e8f6dffc8d7f1f16143a25c
|
|
| BLAKE2b-256 |
8f9c8d4b0de87e46036e1ed18b3b3a9a9aea58d8839b01a73bb505099614db8f
|
File details
Details for the file clay-3.0.2-py3-none-any.whl.
File metadata
- Download URL: clay-3.0.2-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51c710962a22a1e0970710b7e3bca4f955b6b44886a5c9ef4ee6ec5d263f754d
|
|
| MD5 |
b00dfe550a0627e0479333a54ae1ff57
|
|
| BLAKE2b-256 |
c74e0815c25dbc72a562b9920b8395a88be147d1b48dfc1c44a9d4ba3d08485f
|