Giter Club home page Giter Club logo

complexity's Introduction

Hi there 👋

  • 🔭 I’m currently working on AI/ML projects
  • 🌱 I’m currently learning PyTorch, Scikit-Learn, Stable Baselines 3, Gymnasium, Godot
  • 👯 I’m looking to collaborate on Kaggle competitions
  • 🤔 I’m looking for help with getting my daughter to eat her veggies
  • 💬 Ask me about my experiments in teaching a 4-year-old girl math, including complex numbers
  • 📫 How to reach me: Twitter @audreyfeldroy
  • 😄 Pronouns: she/her
  • ⚡ Fun fact: I met my husband @pydanny at PyCon 2010

complexity's People

Contributors

audreyfeldroy avatar friedcell avatar matthewolsson avatar mrobb avatar pydanny avatar uliska avatar zorba-4 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

complexity's Issues

Restructure input/output dirs

input/ should contain:

  • Jinja2 HTML templates
  • LESS or SCSS, if used
  • Readable CSS, if used
  • Un-optimized images
  • Un-minified JS
  • Any other site assets that the user creates
  • Should JSON go into input/json/ or into a dir at the same level as input/? I don't know.

output/ should contain:

  • Rendered HTML files
  • Compiled, minified CSS
  • Minified JS
  • Optimized images (run through optipng and such)
  • Possibly even create a CSS sprite sheet?

It also might be good to rename input/ and output/ to something else. I don't know what exactly.

Installation and Execution Streamlining for Windows

My windows foo may be a bit weak, but installation and execution of Complexity is done from the command line. While this isn't inherently a bug, the creation of an exe (or batch file) or two that would allow a windows user to install and use complexity without having to manually type the directories every time, at the least, or even seeing the command prompt/terminal, at best, would be awesome.

A batch file would likely require typing at least the target project directory. A GUI (perhaps in C++) could let the user choose the file and directory using an explorer prompt.

My findings on the installation process can be found in the notes section here: https://github.com/nekocoder/complexity

My sample batch file, in the files folder, is my crude first attempt at a model for a command line solution.

Support for {% block.super %}

One of the nice features from Django's templating is the ability to add to an existing block (instead of overwriting it). It would be nice if this support was also built into Complexity.

TemplateNotFound Exception on Windows

I was giving complexity a try on Windows and hit this error while trying to generate the second example site. (using Windows 8.1 and Python 3.3.5 64bit)

The problem appears to be related to Windows paths if I were to guess :suspect:

Copying 404.html to www\404.html
Copying 500.html to www\500.html
Copying about.html to www\about/index.html
Copying base.html to False
Copying index.html to www\index.html
Copying repos.html to www\repos/index.html
Copying charts\bar.html to www\charts\bar/index.html
Traceback (most recent call last):
  File "C:\Python33\Scripts\complexity-script.py", line 9, in <module>
    load_entry_point('complexity==0.9.1', 'console_scripts', 'complexity')()
  File "C:\Python33\lib\site-packages\complexity\main.py", line 122, in main
    output_dir = complexity(project_dir=args.project_dir, no_input=False)
  File "C:\Python33\lib\site-packages\complexity\main.py", line 78, in complexity
    generate_html(templates_dir, output_dir, context, unexpanded_templates)
  File "C:\Python33\lib\site-packages\complexity\generate.py", line 135, in generate_html
    generate_html_file(template_filepath, output_dir, env, context, force_unexpanded)
  File "C:\Python33\lib\site-packages\complexity\generate.py", line 73, in generate_html_file
    tmpl = env.get_template(template_filepath)
  File "C:\Python33\lib\site-packages\jinja2\environment.py", line 791, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "C:\Python33\lib\site-packages\jinja2\environment.py", line 765, in _load_template
    template = self.loader.load(self, name, globals)
  File "C:\Python33\lib\site-packages\jinja2\loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "C:\Python33\lib\site-packages\jinja2\loaders.py", line 160, in get_source
    pieces = split_template_path(template)
  File "C:\Python33\lib\site-packages\jinja2\loaders.py", line 31, in split_template_path
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: charts\bar.html

Exclude partial templates from generation

The following partial templates should be excluded from generation:

  • Templates with .part extension
  • Folders in templates/partials

Both of the above should be configurable. Maybe something like this in complexity.yml would exclude files with extension .blah and directories named dont-generate-me/:

excludes:
- dont-generate-me/
- .blah

From @friedcell on Twitter: "my previous solution was to have filename.html.part, but am open to either folder or name filter. needs to be configurable though"

@friedcell any other requirements or things I should know? Other ideas about this? Feel free to file other issues with anything that's annoying or could be better, btw.

I'll try to get this in over the next day, but in the meantime a workaround is to use complexity 0.8.0.

Rename json_dir to context_dir and document

Sometimes you want your .json files to be turned into context vars, and sometimes you don't.

This rename helps to alleviate confusion.

This should all be documented. Something like:

If you don't want your .json files turned into context, they should go into:

  • assets/api/ or assets/json/ if static (What should be the best practice here? Still figuring this out.)
  • possibly templates/json/ if templated? (Do we even want templated .json files that can use data from context/? Not sure...maybe in the future.)

Support for robots.txt and friends

There is currently no way to move static files into the root of the output - this is needed for robots.txt and other similar files.

Possible solutions are to also copy files from assets, not just directories or to allow a special folder (similar to the less/scss exceptions) that would indicate that the files will end up in root. The first solution seems more intuitive.

Better handling of empty context/*.json files

If a context json file is empty, you get:

Traceback (most recent call last):
  File "/home/travis/build/audreyr/complexity/tests/test_main.py", line 43, in test_conf_proj2_with_complexity
    main.complexity('tests/conf_proj2')
  File "/home/travis/build/audreyr/complexity/complexity/main.py", line 66, in complexity
    context = generate_context(context_dir)
  File "/home/travis/build/audreyr/complexity/complexity/generate.py", line 167, in generate_context
    obj = json.load(f)
  File "/usr/lib/python3.3/json/__init__.py", line 274, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.3/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.3/json/decoder.py", line 352, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.3/json/decoder.py", line 370, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Support for more root templates and templates within folder

complexity works really well for simple websites, but it would be nice to have a bit more control over where and how templates appear in the output_dir. For instance, the ability to have 404.html copied directly into output_dir, just like the main index.html.

Also, in some cases it would be great to have the ability to have folders within templates, so the final output would be www/folder/filename/index.html. This could be done by either requiring a special file name (_folder_filename.html) or just adding support for folders. In this case, it would also be helpful to have the ability for assets to copy directly into folders created by templates.

Keep up the good work!

Implement HTML minification

All HTML files should be minified:

  • Remove whitespace and newlines
  • Maybe remove comments, if it can be done in a way that doesn't affect tools that depend on HTML comments. If not, no big deal.

Implement CSS concatenation and minification

When a user generates a Complexity site:

  • All files in project/assets/css/ should be concatenated in the order that they appear in HTML
  • All CSS should be minified with @zacharyvoase's cssmin project

Since this code isn't really Complexity-specific, it might as well be a separate Python package.

I've set up https://github.com/audreyr/csscrunch for this, but it isn't implemented yet. If something else comes along that already does this (fingers crossed that it will), then we can just use that instead.

Implement SCSS compilation

By default, write a function in complexity.generate that uses pyScss.

(This is just for now. Later we can add the option to use the sass Ruby gem, but that's not part of this issue.)

Is this project dead?

I really like the API of this project, but it looks like it may not work on newer versions of Python?

Improve the Complexity tutorial

This is a first attempt at a Complexity tutorial:
http://complexity.readthedocs.org/en/latest/tutorial.html

It could use some reviewing from someone who's never used Complexity:

  • What is confusing?
  • What can be improved?
  • What would make it flow better?

If you have feedback, comment here.

If you have enough experience to feel comfortable doing so, please submit a pull request with improvements. (Don't worry about this if feedback is easier, though.)

python setup.py sdist upload breaks on Python 3

It's fine on Python 2, so that's what I use to upload the package to PyPI.

On Python 3, this happens:

$ python setup.py sdist upload
running sdist
running egg_info
writing dependency_links to complexity.egg-info/dependency_links.txt
writing complexity.egg-info/PKG-INFO
writing requirements to complexity.egg-info/requires.txt
writing top-level names to complexity.egg-info/top_level.txt
writing entry points to complexity.egg-info/entry_points.txt
reading manifest file 'complexity.egg-info/SOURCES.txt'
writing manifest file 'complexity.egg-info/SOURCES.txt'
running check
creating complexity-0.1.1
creating complexity-0.1.1/complexity
creating complexity-0.1.1/complexity.egg-info
making hard links in complexity-0.1.1...
hard linking README.rst -> complexity-0.1.1
hard linking setup.py -> complexity-0.1.1
hard linking complexity/__init__.py -> complexity-0.1.1/complexity
hard linking complexity/complexity.py -> complexity-0.1.1/complexity
hard linking complexity.egg-info/PKG-INFO -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/SOURCES.txt -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/dependency_links.txt -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/entry_points.txt -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/not-zip-safe -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/requires.txt -> complexity-0.1.1/complexity.egg-info
hard linking complexity.egg-info/top_level.txt -> complexity-0.1.1/complexity.egg-info
Writing complexity-0.1.1/setup.cfg
Creating tar archive
removing 'complexity-0.1.1' (and everything under it)
running upload
Traceback (most recent call last):
  File "setup.py", line 56, in <module>
    keywords='complexity static site generator HTML Jinja2 templates S3',
  File "/usr/local/lib/python3.3/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/lib/python3.3/distutils/dist.py", line 917, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.3/distutils/command/upload.py", line 66, in run
    self.upload_file(command, pyversion, filename)
  File "/usr/local/lib/python3.3/distutils/command/upload.py", line 155, in upload_file
    body.write(value)
TypeError: 'str' does not support the buffer interface

Implement image optimization

When a user generates a Complexity site, all images in project/assets/img/ should automatically get optimized.

I normally use optipng for this, but it's not Python and would make installation harder. It would be nice to find a pure Python implementation of something similar. Is there one?

Docker image

I'm using complexity to build a few static sites and have been using it in my CI pipelines. To use it, I needed it in a docker container.

I setup https://github.com/andrewthetechie/complexity-docker to build those images. Right now I'm building images for 3.8, 3.9, and 3.10 versions of python both on alpine and slim images.

If you're interested in a PR, I'd be happy to PR these changes back to this project to have github actions build images right from here.

Encoding varies between systems

I'm using version 0.9.1 of complexity with Python 3. There is no encoding specified when parsing templates and writeing the result to a file. When no encoding is specified, Python 3 uses a default encoding which depends on the system.¹ This might cause different results on different systems while using the same input. This is a problem because the build of a webseite should not depend on the system it is running on. Also note that complexity already specifies an encoding when using Python 2 in contrast to Python 3.

I noticed the problem as I tried to run my build on a system where ASCII is used as default encoding. I got the following error:

Traceback (most recent call last):
  File "./install", line 27, in <module>
    main()
  File "./install", line 22, in main
    complexity("src/", "www/")
  File "/***/site-packages/complexity/main.py", line 78, in complexity
    generate_html(templates_dir, output_dir, context, unexpanded_templates)
  File "/***/site-packages/complexity/generate.py", line 135, in generate_html
    generate_html_file(template_filepath, output_dir, env, context, force_unexpanded)
  File "/***/site-packages/complexity/generate.py", line 82, in generate_html_file
    fh.write(rendered_html)
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 1432: ordinal not in range(128)

The behavior can be reproduced by setting an environemt variable as noted in the here.

$ LC_ALL=C.ascii complexity src/

For example, the following template file cannot be encoded as ASCII and will result in the shown error:

“Quoted”

quickstart www/

сommand not working - $ complexity project/ www/

https://github.com/audreyr/complexity#quickstart

complexity project/ www/

  • www/ parameter not working with that, error says "complexity: error: unrecognized arguments: www/"

complexity project/ - working:

Copying index.html to www/index.html
Copying base.html to False
Copying about.html to www/about/index.html
Copying directory css to www/css
Copying file robots.txt to www/robots.txt
Copying directory img to www/img
Copying directory js to www/js
('serving at port', 9090)
127.0.0.1 - - [04/May/2015 09:02:50] "GET / HTTP/1.1" 200 -

can you explain what happens and how to, may be i'm doing something wrong

HISTORY.rst causes problem with pip install on python 3.6

Using a 3.6 virtualenv, pip install breaks when installing complexity-0.9.1.

The error occurs when reading the HISTORY.rst file, with the first character of the tree diagram in the release notes for 0.4: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2378: ordinal not in range(128)

This seems to be because the content of HISTORY.rst is UTF8, but a non-binary mode open is expecting ASCII, and so the codec errors out.

I was able to "fix" this by hacking setup.py to read HISTORY.rst in binary mode, and decode the resulting buffer as UTF8. I think that'd work for 2.7 also, although I didn't try it.

See also issue #4, which appears to report a related problem with Python 2.7.

Current commandline interface

Commandline usage could improved to allow operators to generate & switch inbetween things like templates, assets without Ruining old CLI, while making it easier to implement new commandline-flags in the future (imho, working with argparse sucks).

I've implemented an alternative CLI (using docopt) within complexity here: https://github.com/jonatanhal/complexity

Using complexity on multi-language site

Hello,

I've made some test and I think using 'complexity' for my website (thanks for this tool).
Have you any suggestions for add a multi-languages functionality to my website with complexity.
My idea is to write all pages in english and use a tool like gettex for create po files and translate them later. Is there already this such possibility in complexity, I don't see anything in doc about that.

Regards

Rethink internal Complexity API

Specifically, some of the functions are being passed input_dir and output_dir params.

It might make more sense to pass them things like json_dir, templates_dir, css_dir, etc.

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.