Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Load all files in a data directory: "_all.yml" and other files if present. #67

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6e5dc92
Load all files in a data directory: "_all.yml" and other files if pre…
PaulPichaureau Mar 17, 2018
cb2ebf4
Content field from _all.yml files are now loaded.
PaulPichaureau Mar 18, 2018
44c12a9
Content field from _all.yml files are now loaded.
PaulPichaureau Mar 18, 2018
725a577
Check if field is present in case of ManyToMany relation
PaulPichaureau Mar 19, 2018
4a43f6e
Merge branch 'debug2'
PaulPichaureau Mar 19, 2018
5076a9b
clean
PaulPichaureau Mar 2, 2019
4a96b8e
Change yaml load to full_load. See https://github.com/yaml/pyyaml/wik…
PaulPichaureau Mar 2, 2019
cc5259b
Ignore pipfile
PaulPichaureau Mar 3, 2019
cd71362
Disable markdown extension
PaulPichaureau Mar 3, 2019
326c0e3
Revert "Change yaml load to full_load. See https://github.com/yaml/py…
PaulPichaureau Mar 2, 2019
bcec899
Change yaml load to full_load. See https://github.com/yaml/pyyaml/wik…
PaulPichaureau Mar 2, 2019
eb576d1
Logging des données non trouvées lors du build
PaulPichaureau Mar 4, 2019
31b882b
clean
PaulPichaureau Mar 8, 2019
7299f6b
Add warnings
PaulPichaureau Mar 8, 2019
4324526
Changement dans la gestion de _all.yml
PaulPichaureau Oct 12, 2019
9db3ae2
La version précise qu'on est en "PP"
PaulPichaureau Jan 22, 2020
4541b11
Change in name of *.yml
PaulPichaureau Feb 10, 2020
2f3ac00
Fixes #64 - last tag registered was invoked for all tag invocations
pztrick Feb 14, 2018
6932b5e
bumping version to v0.21.3
thanethomson Feb 15, 2018
5758022
adding CHANGELOG entry for v0.21.3
thanethomson Feb 15, 2018
42f455a
Updates code to allow for newest version of Markdown library (> 3.0)
Oct 8, 2018
91bd57f
Fixes requirements to latest versions of libraries
Oct 8, 2018
87aae7c
Removes broken import
Oct 8, 2018
290adb3
Updates changelog for v0.22.0
Oct 8, 2018
6c24843
Updates version to v0.22.0
Oct 8, 2018
204b3fd
Fixes missing paramiko requirement
Oct 8, 2018
9cc0fa3
Bumps version to v0.22.1
Oct 8, 2018
84c44c1
Updates changelog for v0.22.1
Oct 8, 2018
ee76604
Updates CHANGELOG for v0.22.2
thanethomson Oct 20, 2018
d139b0e
Bumps version to v0.22.2
thanethomson Oct 20, 2018
625b9be
Adds Python 3.7 to Travis CI build
thanethomson Oct 20, 2018
333037f
Tries Tornado Travis CI approach to be able to build Python 3.7
thanethomson Oct 20, 2018
c6eb4cb
Removes CONTRIBUTORS file in favour of just going to https://github.c…
thanethomson Oct 20, 2018
c530c69
Removes CONTRIBUTORS file in favour of just going to https://github.c…
thanethomson Oct 20, 2018
f6810f3
Updates package tags to include Python 3.7 for next release
thanethomson Oct 20, 2018
4d37d1b
Load all files in a data directory: "_all.yml" and other files if pre…
PaulPichaureau Mar 17, 2018
8cb6876
database.py: Preserve default list value order
CLiu13 Nov 22, 2018
910a8a7
Allow access to variables defined in config in views
kx-chen Dec 4, 2018
d37e02e
database.py: Allow for multiple foreign keys in same document
kx-chen Dec 9, 2018
e7a2a1b
Merge pull request #2 from PaulPichaureau/master-pp
PaulPichaureau Mar 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,10 @@ pip-selfcheck.json
# Generated folders
public/


Pipfile

Pipfile\.lock

.DS_Store
statik.code-workspace
22 changes: 18 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
language: python
python:
- "2.7"
- "3.5"
- "3.6"

# Takes inspiration from https://github.com/tornadoweb/tornado/blob/master/.travis.yml
.mixins:
- &xenial-mixin
dist: xenial
sudo: true
addons:
apt:
packages:
- libgnutls-dev
jobs:
include:
- python: 2.7
- python: 3.5
- python: 3.6
- <<: *xenial-mixin
python: 3.7

install:
- "pip install -r requirements.txt"
script:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ This is the **Statik** change log as of version `0.6.0`.

## Release History

### `v0.22.2` - 20 October 2018

* Merging #74 to better organise the growing list of CLI arguments.

### `v0.22.1` - 8 October 2018

* Minor fix to add missing `paramiko` dependency

### `v0.22.0` - 8 October 2018

* Merges #68
* Merges #73 to add SFTP upload functionality
* Updates dependency versions in `requirements.txt`
* Updates Markdown package integration to use new API

### `v0.21.3` - 15 February 2018

* Merging #65 to fix #64.

### `v0.21.2` - 12 February 2018

* Attempting to fix issues #50 and #63 - automatic translation of special Unicode characters
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTORS

This file was deleted.

Empty file removed examples/blog/models/Tag.yml
Empty file.
10 changes: 10 additions & 0 deletions files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/usr/local/lib/python3.7/site-packages/statik-0.21.2-py3.7.egg
/usr/local/bin/statik
/usr/local/bin/pystache
/usr/local/bin/pystache-test
/usr/local/bin/httpwatcher
/usr/local/bin/slugify
/usr/local/bin/markdown_py
/usr/local/bin/futurize
/usr/local/bin/pasteurize
/usr/local/bin/watchmedo
34 changes: 21 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
future>=0.16.0
jinja2>=2.8
PyYAML>=3.11
SQLAlchemy>=1.0.14
markdown>=2.6.6
python-slugify>=1.2.1
six>=1.10.0
lipsum>=0.1.1
httpwatcher>=0.5.1
mlalchemy>=0.2.1
pystache>=0.5.4
colorlog>=3.1.0
python-dateutil>=2.6.1
wheel
argh==0.26.2
colorlog==3.1.4
future==0.16.0
httpwatcher==0.5.1
Jinja2==2.10
lipsum==0.1.2
Markdown==3.0.1
MarkupSafe==1.0
mlalchemy==0.2.2
pathtools==0.1.2
pystache==0.5.4
python-dateutil==2.7.3
python-slugify==1.2.6
PyYAML==3.13
six==1.11.0
SQLAlchemy==1.2.12
tornado==5.1.1
Unidecode==1.0.22
watchdog==0.9.0
paramiko==2.4.2
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_version():
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Utilities",
]
Expand Down
3 changes: 2 additions & 1 deletion statik/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding:utf-8 -*-

__version__ = "0.21.2"
__version__ = "0.22.2"

43 changes: 22 additions & 21 deletions statik/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class ContentLoadable(object):
loading content and metadata from a Markdown file.
"""
def __init__(self, filename=None, file_type=None, from_string=None, from_dict=None,
name=None, markdown_config=None, encoding='utf-8', error_context=None):
name=None, markdown_config=None, encoding='utf-8', error_context=None,
content_field = None):
self.vars = None
self.content = None
self.file_content = None
Expand Down Expand Up @@ -102,7 +103,6 @@ def __init__(self, filename=None, file_type=None, from_string=None, from_dict=No
"filename", "from_string", "from_dict",
context=self.error_context
)

if name is not None:
self.name = name
elif self.filename is not None:
Expand All @@ -112,7 +112,23 @@ def __init__(self, filename=None, file_type=None, from_string=None, from_dict=No
"name", "filename",
context=self.error_context
)

markdown_ext = [
MarkdownYamlMetaExtension(),
MarkdownLoremIpsumExtension(error_context=self.error_context)
]
if self.markdown_config.enable_permalinks:
markdown_ext.append(
MarkdownPermalinkExtension(
permalink_text=self.markdown_config.permalink_text,
permalink_class=self.markdown_config.permalink_class,
permalink_title=self.markdown_config.permalink_title,
)
)
markdown_ext.extend(self.markdown_config.extensions)
md = Markdown(
extensions=markdown_ext,
extension_configs=self.markdown_config.extension_config
)
# if it wasn't loaded from a dictionary
if self.vars is None:
if self.file_type is None:
Expand All @@ -127,26 +143,11 @@ def __init__(self, filename=None, file_type=None, from_string=None, from_dict=No
if not isinstance(self.vars, dict):
self.vars = {}
else:
markdown_ext = [
MarkdownYamlMetaExtension(),
MarkdownLoremIpsumExtension(error_context=self.error_context)
]
if self.markdown_config.enable_permalinks:
markdown_ext.append(
MarkdownPermalinkExtension(
permalink_text=self.markdown_config.permalink_text,
permalink_class=self.markdown_config.permalink_class,
permalink_title=self.markdown_config.permalink_title,
)
)
markdown_ext.extend(self.markdown_config.extensions)

md = Markdown(
extensions=markdown_ext,
extension_configs=self.markdown_config.extension_config
)
self.content = md.convert(self.file_content)
self.vars = md.meta
else:
if (content_field is not None) and (content_field in self.vars):
self.content = md.convert(self.vars[content_field])

if isinstance(self.vars, dict):
self.vars = dict_strip(self.vars)
6 changes: 3 additions & 3 deletions statik/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def __repr__(self):
def __str__(self):
return repr(self)

def build_dynamic(self, db, safe_mode=False):
def build_dynamic(self, db, extra=None, safe_mode=False):
"""Builds the dynamic context based on our current dynamic context entity and the given
database."""
result = dict()
for var, query in iteritems(self.dynamic):
result[var] = db.query(query, safe_mode=safe_mode)
result[var] = db.query(query, safe_mode=safe_mode, additional_locals=extra)
return result

def build_for_each(self, db, safe_mode=False, extra=None):
Expand All @@ -68,7 +68,7 @@ def build(self, db=None, safe_mode=False, for_each_inst=None, extra=None):
result = copy(self.initial)
result.update(self.static)
if self.dynamic:
result.update(self.build_dynamic(db, safe_mode=safe_mode))
result.update(self.build_dynamic(db, extra=extra, safe_mode=safe_mode))
if self.for_each and for_each_inst:
result.update(self.build_for_each(db, safe_mode=safe_mode, extra=extra))
if isinstance(extra, dict):
Expand Down
Loading