Code Monkey home page Code Monkey logo

statik's Introduction

Statik

Build Status PyPI PyPI

Overview

Statik aims to be a simple, yet powerful, generic static web site generator. Instead of forcing you to adhere to a particular data structure/model (like the standard blog data model, with posts, pages and tags), Statik allows you to define your own data models in YAML format, and instances of those data models either in YAML or Markdown. This is all loaded into an in-memory SQLAlchemy SQLite database when rendering your views.

Then, code up your templates using the Jinja2 templating engine (very similar to the Django templating engine), or Mustache templates.

Finally, define your views (either complex or simple) in YAML format, telling Statik how to render your data and templates to specific URLs for your shiny new static web site. Write queries for your views in SQLAlchemy's ORM syntax, or MLAlchemy to make your life easier.

See the wiki for more details.

Requirements

In order to install Statik, you will need:

  • Python 3.6+
  • pip or easy_install

Installation

Simply run the following:

> pip install statik

To upgrade, just run the following:

> pip install --upgrade statik

Usage

To build the project in the current directory, writing output files to the public directory within the current directory:

> statik

To build a project in another directory, writing output files to the public directory within that directory:

> statik -p /path/to/project/folder

To build a project in another directory, with control over where to place the output files:

> statik -p /path/to/project/folder -o /path/to/output/folder

Project QuickStart

To create an empty project folder with the required project structure, simply run:

> statik -p /path/to/project/ --quickstart

Statik Projects

A Statik project must adhere to the directory structure as follows:

config.yml    - YAML configuration file for the overall project.
assets/       - Static assets for the project (images, CSS files,
                scripts, etc.). Ignored if themes are used.
data/         - Instances for each of the different models, defined either in
                YAML or Markdown format.
models/       - A folder specifically dedicated to model definitions, in YAML
                format.
templates/    - Jinja2/Mustache template files. Ignored if themes are used.
templatetags/ - Python scripts defining custom Jinja2 template tags and
                filters.
themes/       - If your project uses themes, place them here. Each theme
                must be uniquely named, and must contain an "assets"
                and "templates" folder.
views/        - Configuration files, in YAML format, defining "recipes" for how
                to generate various different URLs (which models to use, which
                data and which templates).

For example projects, see the examples directory in the source repository. For more information, see the wiki.

Themes

Themes for Statik will slowly start appearing in the Statik Themes repository. Watch that space!

Remote upload

Statik can publish your generated site for you through SFTP or through Netlify.

SFTP

To publish your website via SFTP, you can configure certain values by way of configuration file or environment variable-based options. Some sensitive options, however, must be configured exclusively by way of environment variables.

For your configuration file:

deploy:
  sftp:
    host: your-server.com
    dest-path: /folder/on/your/server/
    user: youruserforyourserver

    # you can also optionally specify which SSH private key to use
    key-file: ~/.ssh/my-private-key

    # optionally specify SFTP port (default: 22)
    port: 2222

Set up your sensitive environment variables prior to running Statik:

# If your server requires password-based authentication
> export SFTP_PASSWORD=mysftppassword

# If your SSH key file is encrypted and it requires a password to decrypt
> export SFTP_KEY_FILE_PASSWORD=mysftpkeyfilepassword

Alternatively, you could set up all SFTP variables through environment variables alone:

> export SFTP_HOST=your-server.com
> export SFTP_PORT=2222                  # optionally set SFTP port
> export SFTP_DEST_PATH=/folder/on/your/server
> export SFTP_USER=youruserforyourserver
> export SFTP_PASSWORD=mysftppassword
> export SFTP_KEY_FILE=~/.ssh/my-private-key
> export SFTP_KEY_FILE_PASSWORD=mysftpkeyfilepassword

Then run Statik using the following deployment command:

> statik --deploy sftp

For troubleshooting SFTP connections, run this using the -v flag to increase output verbosity:

> statik --deploy sftp -v

Netlify

To publish your website via Netlify, you will need 2 things: your Netlify access token and your Netlify site ID.

First, specify your access token and site ID as environment variables:

Linux:

> export NETLIFY_AUTH_TOKEN=<netlify_token>
> export NETLIFY_SITE_ID=<netlify_site_id>

Windows

> set NETLIFY_AUTH_TOKEN=<netlify_token>
> set NETLIFY_SITE_ID=<netlify_site_id>

Then, run Statik by passing in --deploy=netlify.

statik --deploy netlify

Statik will upload the static site that it outputs.

License

The MIT License (MIT)

Copyright (c) 2016-2019 Thane Thomson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

statik's People

Contributors

cliu13 avatar dhruvsomani avatar hamaluik avatar jayvdb avatar konstruktiv avatar kx-chen avatar nzsmartie avatar paulpichaureau avatar pztrick avatar seeeturtle avatar thanethomson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statik's Issues

sqlalchemy.exc.NoForeignKeysError while watching a folder with empty model file

I get the following exception while watching a folder (when it reloads the content for the first time after changing a file):

sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship Post.tags - there are no foreign keys linking these tables via secondary table 'PostTag'.  Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify 'primaryjoin' and 'secondaryjoin' expressions.

where Post.yml looks as follows:

title: String
slug: String
summary: Text
date: DateTime
tags: Tag[] -> posts
content: Content

and Tag.yml is empty (i.e. only a pk field).

ORM for data access

As opposed to writing SQLite queries, one could simply incorporate something like SQLAlchemy into Statik and provide full ORM access somehow through the templating engine. Would be a really cool feature for the 1.x release series.

Error messages useless

Hi,

thank you for this very interesting project, which could fit perfectly my needs.

The first problem I encounter is the error message, quite useless. For example:

`--- Logging error ---
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/cmdline.py", line 127, in main
generate(config_file_path, output_path=output_path, in_memory=False, safe_mode=args.safe_mode)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/generator.py", line 15, in generate
return project.generate(output_path=output_path, in_memory=in_memory)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 105, in generate
in_memory_result = self.process_views()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/project.py", line 220, in process_views
extra_context=self.project_context
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 366, in process
extra_context=extra_context
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 277, in render
inst_path = self.path.render(inst=inst, context=ctx)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/views.py", line 175, in render
result = self.template.render(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/templating.py", line 293, in render
return self.template.render(**context)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "", line 1, in top-level template code
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jinja2/environment.py", line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'master' is undefined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 992, in emit
msg = self.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 838, in format
return fmt.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 575, in format
record.message = record.getMessage()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/init.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/statik", line 11, in
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statik/cmdline.py", line 134, in main
logger.exception("Exception caught while attempting to generate project", e)
Message: 'Exception caught while attempting to generate project'
Arguments: (UndefinedError("'master' is undefined",),)
`

I just know there is a jinja problem somewhere, but I even don't which of my file is incorrect.

Support for assets

At present, although the README mentions it, there is no support yet for the inclusion of plain assets into the generated project. This must be added ASAP.

Exit with non-zero status code upon error

I'd like to chain the statik command with && and then another command to upload the generated output.

However as it is statik exits with a 0 status whether successful or not so I have to perform other checks before I can upload.

I could probably submit a PR for this if it's something you'd want to incorporate.

Could it be an issue with the in-memory database when there is a lot of data?

Hi,
I'm looking for a static site generator (SSG) for my project in which I need to extract a large amount of data from my database and provide it to the SSG to generate the static site. Statik seems to be exactly what I want. However, there is one thing concerns me:

From the wiki:

Statik allows you to define your own data models in YAML format, and instances of those data models either in YAML or Markdown. This is all loaded into an in-memory SQLAlchemy SQLite database when rendering your views.

I wonder if there is a lot of data (e.g. >20G), would the in-memory database consume all my ram and freeze my computer?

Need to make generated URLs absolute

In building support for serving Atom and RSS feeds, it's going to be important to embed absolute URLs in the feeds for certain feed readers to display the content properly.

Several outputs

Is there possible to define several outputs from a file? I plan to generate a beamer file from markdown one using pandoc. Is it possible? How?

Buit-in webserver injects path segments when accessing correct rendered {% url %}

I get unexpected urls when accessing the site through the built-in webserver, but the html is rendered correct:

in out
template {% url 'album' album %}
html /projects/json2statik/album/eguelshardt-elsass
built-in webserver http://localhost:8000/projects/json2tt/album/album/eguelshardt-elsass/

The /projects/json2statik is defined as base-path.

On the production site it's just fine: the url /projects/json2statik/album/eguelshardt-elsass took me to the expected ressource /projects/json2statik/album/eguelshardt-elsass - but with the built-in webserver I get redirected to http://localhost:8000/projects/json2statik/album/album/eguelshardt-elsass/ - where does this duplication of album came from? Any tips or hints?

Involved views

I link from album_tile_index.yml:

# views/album_tile_index.yml
path: /albums/browse
template: album_tile_index
context:
  dynamic:
    albums: session.query(Album).order_by(Album.sort_by.desc())

to album.yml:

# views/album.yml
path:
  template: /album/{{ album.pk }}
  for-each:
    album: session.query(Album).all()
template: album

Unable to generate output other than html via template parameter with extension other than html

The following view/template combo does not produce a the desired json file, instead yields a

MissingTemplateError('Cannot find template by name: search_index.json',):

# views/search_index.yml
path: /search_index.json
template: search_index.json
context:
  static:
    page-title: Search Index
  dynamic:
    photos: session.query(Photo).all()
    albums: session.query(Album).all()

# templates/search_index.json
does-not-matter

What am I doing wrong? I'd like to generate a json file and name the template file accordingly. When switching the file extension to .html everything works as expected.

Allow importing python modules for dynamic context

Use case: Having a project-wide compilation-date for template usage.

context:
  dynamic:
    compliation-date: from datetime import date; date.today().isoformat()
<section id="footer_generated_on">
	<span>Generated on {{ compilation_date }}</span>
</section>

If done with a custom jinja tag, the date would be generated each time called.

statik --watch: OSError: [Errno 99] Cannot assign requested address

On a Debian 9.1 host, when I try to run the examples/blog project or a custom statik project via statik --watch, I got the following error:

(venv) breitner@breitner-vm-debian-x:~/projects/statik/examples/blog$ statik --watch
Project path configured as: /home/breitner/projects/statik/examples/blog
Using encoding: utf-8
Writing output file: /home/breitner/projects/statik/examples/blog/public/rand-example/index.html
Writing output file: /home/breitner/projects/statik/examples/blog/public/2016/06/01/first-post/index.html
Writing output file: /home/breitner/projects/statik/examples/blog/public/2016/06/04/second-post/index.html
Writing output file: /home/breitner/projects/statik/examples/blog/public/2016/06/30/html-content-test/index.html
Writing output file: /home/breitner/projects/statik/examples/blog/public/index.html
Writing output file: /home/breitner/projects/statik/examples/blog/public/slugify-example/index.html
Wrote 6 output file(s) to folder: /home/breitner/projects/statik/examples/blog/public
Copying assets from /home/breitner/projects/statik/examples/blog/assets to /home/breitner/projects/statik/examples/blog/public/assets...
Copied 1 asset(s)
--- Logging error ---
Traceback (most recent call last):
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/statik/cmdline.py", line 102, in main
    safe_mode=args.safe_mode)
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/statik/watcher.py", line 75, in watch
    open_browser=open_browser
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/httpwatcher/cmdline.py", line 49, in watch
    server.listen()
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/httpwatcher/server.py", line 98, in listen
    super(HttpWatcherServer, self).listen(self.port, address=self.host, **kwargs)
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/tornado/web.py", line 1943, in listen
    server.listen(port, address)
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 981, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 831, in format
    return fmt.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 568, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.5/logging/__init__.py", line 331, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/breitner/projects/statik/examples/blog/venv/bin/statik", line 11, in <module>
    sys.exit(main())
  File "/home/breitner/projects/statik/examples/blog/venv/lib/python3.5/site-packages/statik/cmdline.py", line 113, in main
    logger.exception("Exception caught while attempting to generate project", e)
Message: 'Exception caught while attempting to generate project'
Arguments: (OSError(99, 'Cannot assign requested address'),)
(venv) breitner@breitner-vm-debian-x:~/projects/statik/examples/blog$ 

I followed your setup/installation procedure from your documentation, using python 3.5.3 and a virtual environment. Generating the site via statik finished without any error (see above).

The same projects run just fine on another Debian Stretch host. Unfortunately, I have no idea how I can fix this error...

Support for syntax highlighting output in Markdown

One of the major features of blog-oriented static website generators is to provide syntax highlighting. This could be accomplished client-side with the inclusion of certain libraries such as highlight.js, but one would also need support for server-side rendering, such as that provided by Pygments.

Dependency versions

Is there any chance we could specify minimum acceptable versions of dependency packages and just manage breaking changes as they come? I don't have access to virtualenv in my current setup, so I haven't been able to install statik yet because of version requirements conflicting with what's already installed on my system.

As an example, this is the approach Pelican currently takes.
https://github.com/getpelican/pelican/blob/master/setup.py

Custom SQL query on model-based views

At present, model-based views automatically fetch all instances for a particular model, but there are cases where such queries need to be customised to limit the instances returned.

Error caught super() / no "shutdown"

Hi !
I tried to re-run what I think is the example project of the wiki walkthrough.
with statik 0.7.0:

$ statik                                                                      
Project path configured as: /home/vince/bacasable/statiktest
Error caught: super() takes at least 1 argument (0 given)
Unable to clean up properly: 'NoneType' object has no attribute 'shutdown'

Any idea ? (tried with py2 and 3)

ps: idea: provide the example project of the walkthrough as a git project, so that I'm sure I'm doing well, I can extend this base, and so we can test and update it with the newer statik versions.

Python 3

It doesn't seem to work in Python 3. What a shame...

(env) 02:39:47 (master) /tmp/statik/examples/blog$ statik
Project path configured as: /tmp/statik/examples/blog
Error caught: name 'unicode' is not defined

How to disable html entities?

Given that utf-8 is everywhere nowadays, I would like to just use unicode symbols in my markdown source files (such as θ), and leave them as their unicode symbol (ie θ, not &#952;). This particularly messes with inline code (between ` tags).

If my source file contains:

Some text with a `θ` in it

It renders to:

<p>Some text with a <code>&#952;</code> in it</p>

Which of course displays as:

Some text with a &#952; in it

Instead of what I want, which is:

Some text with a θ in it

Thanks!

Field validation support on model field values

Field validation is necessary on certain kinds of fields. For example, if you have a String field that is meant to only contain e-mail addresses, or perhaps URLs, you would want to have Statik validate those field values.

Acces for-each context from model linked via fk

Hi,
I have an Album and a Photo model, each Photo has a FK to the corresponding album. In my album.yml-view I set a for-each-context for a photos_count property:

path:
  template: /album/{{ album.pk }}
  for-each:
    album: session.query(Album).all()
template: album
context:
  for-each:
    photos: session.query(Photo).filter(Photo.album == album).all()
    geo_refs: list(map(list, list(session.query(Photo).filter(Photo.album == album).values('name', 'geo_lat', 'geo_lon'))))
    photos_count: session.query(Photo).filter(Photo.album == album).count()

Now I would like to access this property photos.count also in my photo.html template:

{{ photo.album.name }} / {{ photo.album.photos_count }} photos

... but this will not work out of the box.

Any Ideas how to inject the photos_count per album in the photo template without code duplication?

PS: Please let my know if your issue tracker is not the right place for my questions - if only there would exist a stackoverflow Statik-tag...

Error on statick --quickstart: invalid syntax ?

Hi !
I installed statik in a venv with your recommendation (using pip3),
on statick --quickstart I get this:

$ statik --quickstart      
Traceback (most recent call last):
  File "/home/vince/bacasable/statiktest/bin/statik", line 7, in <module>
    from statik.cmdline import main
  File "/home/vince/bacasable/statiktest/lib/python3.4/site-packages/statik/cmdline.py", line 7, in <module>
    from statik.generator import generate
  File "/home/vince/bacasable/statiktest/lib/python3.4/site-packages/statik/generator.py", line 3, in <module>
    from statik.project import StatikProject
  File "/home/vince/bacasable/statiktest/lib/python3.4/site-packages/statik/project.py", line 12, in <module>
    from statik.database import StatikDatabase
  File "/home/vince/bacasable/statiktest/lib/python3.4/site-packages/statik/database.py", line 398
    **kwargs,
            ^
SyntaxError: invalid syntax

Is there a trailing coma here or did I unlearn python during summer ?

thx and keep up !

Support for YAML

At present, only JSON is supported as a format for defining models, instance preambles and views, but some users would prefer to use YAML.

{% url %} Template tag always adds trailing slash

I'm generating a json file with a dedicated view

# view/search_index.yml
path: /tipuesearch_content.js
template: tipuesearch_content
context:
  dynamic:
    photos: session.query(Photo).all()

and would like to link to the generated file (here: public/tipuesearch_content.js) with the url template tag:

# templates/
<script src="{% url 'search_index' %}"></script> 

I expected a generated string like:
<script src="/tipuesearch_content.js"></script>
but I got
<script src="/tipuesearch_content.js/"></script>

How can I get rid of this trailing slash?

"statik" encounter error

hi.

root@AR:/usr/local/statik-site# statik
Traceback (most recent call last):
File "/usr/local/bin/statik", line 7, in
from statik.cmdline import main
File "/usr/local/lib/python2.7/dist-packages/statik/cmdline.py", line 11, in
from statik.watcher import watch
File "/usr/local/lib/python2.7/dist-packages/statik/watcher.py", line 6, in
import httpwatcher
File "/usr/local/lib/python2.7/dist-packages/httpwatcher/init.py", line 4, in
from httpwatcher.server import *
File "/usr/local/lib/python2.7/dist-packages/httpwatcher/server.py", line 18, in
from httpwatcher.filesystem import FileSystemWatcher
File "/usr/local/lib/python2.7/dist-packages/httpwatcher/filesystem.py", line 15, in
from tornado.queues import Queue
ImportError: No module named queues
root@AR:/usr/local/statik-site# pip install queues
Requirement already satisfied: queues in /usr/local/lib/python2.7/dist-packages
root@AR:/usr/local/statik-site#
then i ran "statik", still encountered error above.

hwo to fix it?
thank you.

Batteries-included RSS/Atom feed support

RSS/Atom feeds should be generated automatically from configuration options in the project's config.yml file.

e.g.

project-name: RSS demo project
base-path: /
feeds:
  posts:
    file: /feeds/posts.xml
    query: session.query(Post).order_by(Post.date.desc())
  projects:
    file: /feeds/projects.xml
    query: session.query(Project).order_by(Project.released.desc())

Windows support

At present, there is limited testing and support for Windows. One particular issue is the path handling that is UNIX/OSX-specific. Support for Windows filesystems/paths is a long-term must.

How to access a variable defined in config.py in a view?

Hi,

I would like to store a project wide variable in my config.py:

# config.py
project-name: myproject
context:
  static:
    my_threshold: 270

... and use this variable (here: my_threshold) in some views:

# views/foo.py
path: /foo
context:
  dynamic:
    render_elem: True if session.query(Bar).count() <= my_threshold else False

but accessing the variable seems not to be defined.

Is something like this possible?

Enable quiet output for Statik

I'm generating a Statik project via .gitlab-ci.yml, but I got (gitlab-) errors because

Writing output fi
�[31;1mJob's log exceeded limit of 4194304 bytes.�[0;m

This project has do deal with a lot of (generated) pages (from data/Photos/_all.yml):

public$ find . -type  f  |wc -l
56350

... and perhaps my gitlab runner would not fail when I could run Statik in a quiet mode (which only outputs errors), like statik --quiet.
Or I write a wrapper script which suppresses the output...

Unable to set a link via {% url %} to a specific instance

I have a model for regular pages which are used for things like Contact, About etc. defined in the following view:

# views/page.yml
path:
  template: /{{ page.slug }}  
  for-each:
    page: session.query(Page).all()
template: page

and the following data:

# data/Page/contact.md
---
title: Contact
slug: contact
---

How do I generate a link to an instance of page?

I tried {% url 'page', contact' %}, but that does not generate the expected href /contact/.

If I loop loop over a dynamic context variable in which all Page objects are stored, links get rendered as expected:

# views/someview.yml
context:
  dynamic:
    static_pages: session.query(Page).all()
# templates/sometemplate.html
{% for page in static_pages %}
  * {% url 'page', page %}
{% endfor %}

Generating files with no extension (.htaccess)

Hi,

I was trying to automatically place a .htaccess-file in my generated website. It works for sitemap.xml and robots.txt, but without an extension, statik creates a .htaccess/index.html.

I would work on a pull request, but first I want to know if I am missing something or if there is any other way to solve this.

Can't have multiple foreign keys in the same document

I created a model, let's just call it Foo in this example, so

Foo.yml contains

Title: String
Value: Integer

and then let's say I want to have Bar contain multiple Foo's

Bar.yml contains

foo1: Foo
foo2: Foo

I can't- I get an error such as:

Error caught: Could not determine join condition between parent/child
tables on relationship Bar.foo1 - there are multiple foreign key
paths linking the tables. Specify the 'foreign_keys' argument,
providing a list of those columns which should be counted as
containing a foreign key reference to the parent table.
Unable to clean up properly: 'NoneType' object has no attribute 'shutdown'

I'm unsure how to resolve this other than by creating foo1 and foo2 models, but that seems very ugly.

Project template creation from command line

Statik needs a way to allow users to create a new project, with the required folder structure, in a quick and easy way. Something like:

> statik --new /path/to/new/project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.