eudicots / cactus Goto Github PK
View Code? Open in Web Editor NEWStatic site generator for designers. Uses Python and Django templates.
License: BSD 3-Clause "New" or "Revised" License
Static site generator for designers. Uses Python and Django templates.
License: BSD 3-Clause "New" or "Revised" License
I'm unable to deploy to S3 on us-west-2 because boto.connect_s3 in deployment/s3/engine.py explicitly sets host to s3.amazonaws.com which causes Broken Pipe Errors. Leaving host unset in this call solves the problem (by presumably letting boto auto-set the correct host), at least for boto 2.28.0 on my system. See related at boto/boto#621
Allow the user to pass an absolute path to cactus build
to control where the build is output.
Once # 30 is merged, the following diff implements this feature.
diff --git a/cactus/models.py b/cactus/models.py
new file mode 100644
index 0000000..e69de29
diff --git a/cactus/site.py b/cactus/site.py
index 0650d8f..f6e1f35 100644
--- a/cactus/site.py
+++ b/cactus/site.py
@@ -61,7 +61,9 @@ class Site(object):
logging.exception("Caught exception while opening config file")
config = {}
- config.setdefault("INSTALLED_APPS", []).append("django.contrib.markup")
+ config.setdefault("INSTALLED_APPS", []).extends(
+ ["django.contrib.markup", "cactus"]
+ )
config.setdefault("TEMPLATE_DIRS", []).extend(
[self.paths['templates'], self.paths['pages']],
)
@@ -358,6 +360,7 @@ class Site(object):
# Set an id based on the file name
plugin.id = pluginHandle
+ sys.modules["cactus.templatetags.%s" % pluginHandle] = plugin
plugins.append(plugin)
# Sort the plugins by their defined order (optional)
diff --git a/cactus/templatetags/__init__.py b/cactus/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
It is a bit hacky, I am making cactus project itself a valid django app by adding cactus.models module and cactus.templatetags package. Then I am putting all plugins available as cactus.templatestags.PLUGIN_NAME, Sample plugin, plugins/t.py:
from django import template
import random
register = template.Library()
@register.filter
def randomize(value):
return "".join(random.sample(value, len(value)))
To use it in template:
{% extends "base.html" %}
{% load t %}
{% block content %}
{{ "Welcome to Cactus!"|randomize }}
{% endblock %}
I thought of some naming convention for plugins, so only some plugins are added to cactus.templatetags.PLUGIN_NAME, but rejected it as now I can ship a blog plugin that contains both plugin hooks and custom templatetag libraries all related to blogging, list of posts etc.
Since it's a RC from Compass I don't know if it's an issue to check but here it goes:
I'm working with the Cactus Mac App on Mavericks 10.9.4
Ruby Gems Installed:
When I run compas compile
from the Mac terminal it works fine. But the Cactus console is showing me a weird error:
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:128:in `require': cannot load such file -- sass/script/node (LoadError)
The Cactus Mac App does not compile the file with the command at the plugin default.py
, but when I run the same command at the Mac terminal it works.
The warning does not appear when I use:
UPDATE 1: With Cactus terminal v2.3.1 and v3 Compass1.0.0.RC1 works fine, even the errors are shown correctly.
pypi version of Cactus not define max django version
The current install instructions "sudo easy_install cactus" do not download the latest release. The v2.2.0 a50b381 release is downloaded and not the newer 2.2.0 9f12e1b release that fixes the version 2.1.3 typo.
Also I would suggest replacing easy_install with "sudo pip install cactus".
And since there have been a number of bug fixes since the last release it might be nice to include instructions on how to download and install the latest "development version" from the master branch.
This is what I did:
"pip install https://github.com/koenbok/Cactus/tarball/master#egg=Cactus-master"
no offence to S3 but with the free threshold on AppEngine it would be great to have an option to deploy to there rather than S3. I'll admit to not having spent much time with Cactus yet so not sure how big a job it would be, but just something to consider.
Also, include a sample starting point css file.
When I run cactus build
or cactus serve
, I get errors related to my use of optimize in config.json
:
Could not call external processor YUICSSOptimizer: [Errno 2] No such file or directory
Could not call external processor ClosureJSOptimizer: [Errno 2] No such file or directory
When I load up a console, importing them like static/static_optimizers.py
does loads them no problem, so I don't know what I'm doing wrong.
>>> from cactus.contrib.external.yui import YUICSSOptimizer`
I'm using the v3 branch.
My config.json
:
{
"fingerprint": [
"js",
"css"
],
"optimize": [
"js",
"css"
],
"prettify": true
}
When I run cactus serve
on a site using the restructuredtext
template tag, the page fails to rebuild due to the following error:
Building index.html<string>:: (ERROR/3) Cannot embed stylesheet '../env/lib/python2.7/site-packages/docutils/writers/html4css1/html4css1.css': No such file or directory.
*** Error while building[Errno 2] No such file or directory: '../env/lib/python2.7/site-packages/docutils/writers/html4css1/template.txt'
It looks like docutils is using a relative path to embed its stylesheets. The regeneration fails because Cactus changes its working directory using os.chdir()
prior to serving pages.
Exactly the same as mentioned here;
https://code.google.com/p/apptrace/issues/detail?id=8
and solved in exactly the same way - I manually patched the site.py file and it worked no problem.
I feel s3cmd is easy enough, s3cmd sync --acl-public --guess-mime-type .build s3://{MY-BUCKET}/. Site.upload() is one of the biggest methods in Site class and it is does less than s3cmd sync. We may put s3cmd as an optional dependency and update cli.py to call it instead of calling site.upload().
We can then think of maybe supporting a few more things, rsync, sftp etc as part of cli.py.
I'm getting nothing (a blank) from the ROOT_URL tag.
If "prettify" is true the error file is located at /error/index.html but server.py still looks for /error.html.
Any plans to support non-default Rackspace regions? We would like to deploy to Sydney but don't see any way to do so. Thanks!
Cactus is building all files in my pages/ directory including text editor backup files with a tilde suffix, e.g. index.html~
as created by my Emacs and gedit text editors.
It would be great if cactus would just skip building those files when running cactus serve
.
Thanks
Is there any reason that the scss files are also copied to the build directory?
If not, wouldn't it be better to just remove them from the .build/static/css directory?
Punching in sudo easy_install cactus
in the Terminal, isn't working out. Here is the problem:
Searching for cactus
Reading http://pypi.python.org/simple/cactus/
Best match: Cactus 2.2.1
Downloading https://github.com/koenbok/Cactus/tarball/v2.2.1#egg=Cactus-2.2.1
error: Can't download https://github.com/koenbok/Cactus/tarball/v2.2.1: 404 Not Found
When installing cactus as advised, I see the error listed below.
$ sudo easy_install ~/Downloads/koenbok-Cactus-v2.1.0-1-ga53a9a4.zip
Processing koenbok-Cactus-v2.1.0-1-ga53a9a4.zip
Writing /tmp/easy_install-GMBxiW/koenbok-Cactus-a53a9a4/setup.cfg
Running koenbok-Cactus-a53a9a4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-GMBxiW/koenbok-Cactus-a53a9a4/egg-dist-tmp-vyX3oo
error: README.md: No such file or directory
This is quite right as the file in the zip is readme.md (i.e. lowercase) but the setup.py script is looking for the uppercase filename.
For some reason cactus serve
on my Mac works terribly slow – server hangs for ~2 minutes before responding.
Replacing ForkingMixin with ThreadingMixin fixes the problem for me.
Python 2.7.1, OS X 10.7.4
Cactus allows it to multilingual sites?
Example : mywebsite.com/fr/... mywebsute.com/en/...
First of all, awesome super simple static generator.
I'm confused as how the markdown plugin works, it seems that you need to add the 'extends' and 'block' meta values at the top of your .md file but I can't seem to get anywhere.
What needs to be present for it to work?
Right now there is only cactus deploy
to deploy on Amazon S3, is there anyway to deploy locally, i.e. generate HTML locally so that one can upload it to his own server?
After I drop the Bootstrap Folder with scss files in the static files, I get this ERROR
/Library/Python/2.7/site-packages/pyScss-1.2.0.post3-py2.7.egg/scss/init.py:86: RuntimeWarning: Scanning acceleration disabled (_speedups not found)!
RuntimeWarning
Error: Could not load plugin at path /Users/Luis/Desktop/bs-test/plugins/scss.py
Error evaluating expression:
$alert-padding
From <string '//\n// Alerts\n// ----------------------------------'...>:1
Traceback:
File "/Library/Python/2.7/site-packages/pyScss-1.2.0.post3-py2.7.egg/scss/expression.py", line 130, in evaluate_expression
return ast.evaluate(self, divide=divide)
File "/Library/Python/2.7/site-packages/pyScss-1.2.0.post3-py2.7.egg/scss/expression.py", line 359, in evaluate
raise SyntaxError("Undefined variable: '%s'." % self.name)
SyntaxError: Undefined variable: '$alert-padding'.
Hi all,
I'm trying to use blog plugin on site hosted on gh-pages and I get the following error:
$ cactus serve
No configuration file found at config.json
Traceback (most recent call last):
File "/usr/local/bin/cactus", line 9, in <module>
load_entry_point('Cactus==3.0.0', 'console_scripts', 'cactus')()
File "/usr/local/lib/python2.7/dist-packages/cactus/cli.py", line 114, in main
args.target(**{k: v for k, v in vars(args).items() if k != 'target'})
File "/usr/local/lib/python2.7/dist-packages/cactus/cli.py", line 54, in serve
site.serve(port=port, browser=browser)
File "/usr/local/lib/python2.7/dist-packages/cactus/site.py", line 440, in serve
self.build()
File "/usr/local/lib/python2.7/dist-packages/cactus/site.py", line 240, in build
self.plugin_manager.preBuild(self)
File "/usr/local/lib/python2.7/dist-packages/cactus/plugin/manager.py", line 31, in call
_meth(*args, **kwargs)
File "/home/claudyus/code/LXC-Web-Panel/gh-pages/site-src/plugins/blog.py", line 54, in preBuild
postContext['body'] = getNode(get_template(page.path), name="news")
File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 138, in get_template
template, origin = find_template(template_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 121, in find_template
loader = find_template_loader(loader_name)
File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 94, in find_template_loader
TemplateLoader = import_by_path(loader)
File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
module = import_module(module_path)
File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/usr/lib/python2.7/dist-packages/django/template/loaders/app_directories.py", line 25, in <module>
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError django.contrib.markup: No module named markup
In https://docs.djangoproject.com/en/1.7/internals/deprecation/ the django.contrib.markup was deprecated in Django=1.6 while pip install cactus
installer Django=1.6.1
How to around the issues?
$ sudo pip install cactus
Requirement already satisfied (use --upgrade to upgrade): cactus in /usr/local/lib/python2.7/dist-packages
Downloading/unpacking Django==1.5.5 (from cactus)
Downloading Django-1.5.5.tar.gz (8.1MB): 8.1MB downloaded
Running setup.py (path:/tmp/pip_build_root/Django/setup.py) egg_info for package Django
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Requirement already satisfied (use --upgrade to upgrade): markdown2 in /usr/local/lib/python2.7/dist-packages (from cactus)
Requirement already satisfied (use --upgrade to upgrade): argparse in /usr/lib/python2.7 (from cactus)
Requirement already satisfied (use --upgrade to upgrade): keyring in /usr/lib/python2.7/dist-packages (from cactus)
Requirement already satisfied (use --upgrade to upgrade): boto>=2.4.1 in /usr/lib/python2.7/dist-packages (from cactus)
Downloading/unpacking tornado>=3.2 (from cactus)
Downloading tornado-4.0.1.tar.gz (314kB): 314kB downloaded
Running setup.py (path:/tmp/pip_build_root/tornado/setup.py) egg_info for package tornado
Requirement already satisfied (use --upgrade to upgrade): colorlog in /usr/local/lib/python2.7/dist-packages (from cactus)
Requirement already satisfied (use --upgrade to upgrade): certifi in /usr/local/lib/python2.7/dist-packages (from tornado>=3.2->cactus)
Requirement already satisfied (use --upgrade to upgrade): backports.ssl-match-hostname in /usr/local/lib/python2.7/dist-packages (from tornado>=3.2->cactus)
Installing collected packages: Django, tornado
Found existing installation: Django 1.6.1
Uninstalling Django:
Successfully uninstalled Django
Running setup.py install for Django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
changing mode of /usr/local/bin/django-admin.py to 755
========
WARNING!
========
You have just installed Django over top of an existing
installation, without removing it first. Because of this,
your install may now include extraneous files from a
previous version that have since been removed from
Django. This is known to cause a variety of problems. You
should manually remove the
/usr/lib/python2.7/dist-packages/django
directory and re-install Django.
Found existing installation: tornado 3.1.1
Uninstalling tornado:
Successfully uninstalled tornado
Running setup.py install for tornado
building 'tornado.speedups' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c tornado/speedups.c -o build/temp.linux-x86_64-2.7/tornado/speedups.o
tornado/speedups.c:49:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
initspeedups() {
^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/tornado/speedups.o -o build/lib.linux-x86_64-2.7/tornado/speedups.so
Successfully installed Django tornado
Cleaning up...
I always use fenced code blocks for my source code, just like on github. It'd be awesome if Cactus could support this. I can help add it, if you have any pointers on where to look.
Cactus is amazing, but I'm curious as to the choice of markdown2 over the original python markdown? There's the impression that markdown2 is faster than markdown, but this is simply not true, e.g.:
http://lepture.com/en/2014/markdown-parsers-in-python
trentm/python-markdown2#154
I've used both and vastly prefer the original markdown - it's much simpler to write plugins/mods for python-markdown as it's built to be extensible. (This is critical for things like Mathjax, where you need to tweak the parsing/transform order to preserve mathematical content.)
the readme says that the "create" syntax is cactus [path] create
but i believe that it is cactus create [path]
that's in the extended guide part of the readme. the syntax is correct in the quick tutorial section.
Is this on the roadmap? What problems are in making this happen?
Cactus looks pretty cool, but part of what we're looking for when we found it is a way to consistently start projects with a common base template, CSS/JS stuff, etc.
I'm considering implementing something that passes options to cactus create to support this. My thought is first, to replace the simple CLI parsing with (argparse)[http://docs.python.org/2/library/argparse.html], and then to pass options to the create method. I'm guessing one option would be a completely alternative root, which would be used in place of the 'skeleton' dir in the package distribution (or possibly in addition to? opinions on that?) and maybe another set of options that would allow people to override only some of those directories. Probably something like:
cactus create --pages=/path/to/pages --static=/path/to/static
where only the specified dirs would be copied.
It would also be neat if you could pull the files from a URL like you can with (django-admin.py startproject [https://docs.djangoproject.com/en/dev/ref/django-admin/#startproject-projectname-destination] -- although that seems challenging.
anyway, thought I'd throw this out before I get too far in case people have opinions or objections. Not that I wouldn't do it, but i wouldn't worry about making a pull request which would be accepted....
Changing SCSS files doesn't seem to update the compiled CSS files when the SCSS plugin is activated and cactus is watching the directory as a server (ie. cactus serve
).
Looking at the project files, it appears the compiled CSS files are never compiled in either static/css
or .build/static/css
when cactus serve
is running even though the standard build message (*** Rebuilding (/path/to/project changed)
) is displayed in the console.
Furthermore, the SCSS files are compiled to CSS files when non-SCSS (e.g. .html
) files are saved, when the server is launched (cactus serve
) or relaunched (via quitting the server with CTRL+C
and restarting with cactus serve
).
My expectation would be that SCSS files are compiled to CSS when a .scss
file is saved.
Happy to help debug in any way that I can. I spent a little bit of time digging through the cactus source to try to find a place to start and submit a patch but I'm a bit stuck so I thought I'd try submitting an issue.
Not sure if it's there already, but I looked and couldn't find it. What I'm looking for is something like the File › Export… option in Cactus for Mac, but for the command line interface.
Thanks in advance : )
I think we should not just worry about plugins, but also about themes. Themes would be a bit more complicated because of static assets going to a different location compared to html files. May be we can do a themes folder, that contains a folder for each theme, and theme specific folder contains two folders, templates and static. We select the theme in _config.yaml and put the theme specific folder at the beginning of django's templatedirs setting, and copy theme specific setting file to global static folder static/themename/ folder.
www.example.com
+ pages
- _config.yaml
- themes
+ default
+ twitter
- the-minimum
- _config.yaml <- merge this file to site _config.yaml if present
+ templates
+ static
+ templates
- static
+ the-minimum [content of themes/the-minimum/static]
When I ran
cactus create test
it created a directory with this layout:
$ ls test
skeleton/
$ ls test/skeleton/
pages/ plugins/ static/ templates/
rather than placing the skeleton files in the test
directory.
cactus deploy
works but gives the following error on Linux (and fails to store AWS private key):
sh: 1: security: not found
It's a shame to have this simple issue because all the rest works flawlessly.
I see it's because Cactus assumes it's running on Mac and uses OS X security
command to store the password. Could we release this assumption (checking sys.platform
or something). Also, why not support keeping the private key on config.json
? Is it because of some security policy?. It could also be handy to support the standard environment variables (ie. AWS_SECRET_ACCESS_KEY
) which boto does by default, but that behavior is overridden.
Is there any way to integrate search for a Cactus blog?
In the docs you mention a config.json file, but when I cactus create <foo>
, there is no config file created. Where does it go?
I am one of the maintainers of Boto. A few weeks ago we began to merge backward-compatible Python 3.3 and 3.4 support into our develop
branch. Most modules now support Python 3 with passing unit and integration tests, and I am hoping to do a release soon. I am reaching out to you to ask if you would test our develop
branch with Cactus.
Testing against Python 2.x will help to ensure that we don't accidentally break third party modules like Cactus. If you would like, you may also try out the Python 3 support and let us know any feedback. More information about the Python 3 support can be found in this boto-users post:
https://groups.google.com/forum/#!topic/boto-users/vcvoy8zrfP8
I appreciate any time that you can put into helping the Boto project with this.
This request is part of boto/boto#2437
While I love what y'all have done for deploying to S3, it'd be great to have more options for deployment. These could be set via the config.
Hi, sorry to be dense, but following the readme docs in cactus and your cactus blog example repo (slightly modified by having installed cactus into a virtual environment), i end up with a big, ugly traceback ending with ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
what i'd like to accomplish is to install cactus into a python venv, ideally such that i can run the latest and greatest by just keeping a git repo up to date, and then get the blogging environment set up which i apparently don't grok how to do correctly.
any pointers on setting things up intelligently, beyond what is in the readme would be very appreciated.
If I run cactus
from the command line without any arguments then I get the expected
help function. However, if I try to create a new site I get the
following:
$ cactus create some_random_site_name
Traceback (most recent call last):
File "C:\Python27\Scripts\cactus-script.py", line 8, in
load_entry_point('cactus==2.1.3', 'console_scripts', 'cactus')()
File "C:\Python27\lib\site-packages\cactus-2.1.3-py2.7.egg\cactus\cli.py",
line 72, in main
create(option1)
File "C:\Python27\lib\site-packages\cactus-2.1.3-py2.7.egg\cactus\cli.py",
line 20, in create
site.bootstrap()
File "C:\Python27\lib\site-packages\cactus-2.1.3-py2.7.egg\cactus\site.py",
line 78, in bootstrap
f = open(tempSkeletonPath, 'w')
IOError: [Errno 2] No such file or directory: '/tmp/skeleton.tar.gz'
I'm using Windows 8 and don't recall seeing any error message when
installing cactus. I've tried running this in both the Windows command
prompt and Cygwin
Would love to put the content of the most recent post on the front page, but find
within the blog.py
plugin can't access the content of my post and I'm not seeing it as one of the values.
The page object has access to the rendered and raw versions, but that includes all the cruft around the base extend.
This system is great by the way
In general it is a good idea to have a separate folder for static content, but for what is a static site generator, forcing this is not a good idea in my opinion.
In my current jekyll powered site I have folders that are self contained, contains images, css, minified js along with html, using relative paths. I would like to continue to do this, but currently adding binary file in pages in not supported.
I suggest we do metadata based template handling only on .html files. If my suggestion in issue # 15 goes through .md files etc would be converted to .html before we start processing files so it would handle all markups.
Feature request: use the django translation mechanisms, via the {% trans %} tag and friends, to create multilingual sites.
Need to specify which languages, and where to create the built sites (eg build/en/ and build/fr/ perhaps?).
Should be as simple as (ha!) looping over the languages, setting the language, and rendering the pages into the right location.
That should cover html, not sure about Javascript...
I'd like a monthly archive index page to be generated for each month for which blog posts exist.
I'm thinking of adding this functionality to the blog.py
plugin in the skeleton template.
Is there a better way to approach this? Would you recommend, for example, that I create a new plugin?
The difference is that these pages won't exist in the pages
directory -- they'll exist only as rendered pages in the .build
directory. I'm not sure how this best fits.
I'd love any advice you can offer. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.