Giter Club home page Giter Club logo

django-bakery's Introduction

                   
                # # # # #
              __#_#_#_#_#__
             {_` ` ` ` ` `_}
            _{_._._._._._._}_
           {_  D J A N G O  _}
          _{_._._._._._._._._}_
         {_    B A K E R Y    _}
     .---{_._._._._._._._._._._}---.
    (   `"""""""""""""""""""""""`   )
     `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

A set of helpers for baking your Django site out as flat files

Features

  • Models, views and management commands that will build your site as flat files.
  • Management commands to sync your flat files with a bucket on Amazon S3.
  • Optional integration of a Celery job queue to automatically build and publish model objects when they are saved

django-bakery's People

Contributors

153957 avatar achavez avatar bmihelac avatar clintonb avatar dependabot[bot] avatar ghing avatar ginabythebay avatar j-e-d avatar joshk avatar luto avatar marycaroline avatar mattaustin avatar meli-lewis avatar ninepints avatar palewire avatar philgyford avatar phjudge avatar ramonakira avatar rixx avatar sahilchinoy avatar schwanksta avatar sheats avatar stard0g avatar temaput 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-bakery's Issues

ImportError: No module named urls

Hi there,

Firstly well done on this awesome app. Loving it.

I've run into a small issue with /bakery/management/commands/buildserver.py line 1 specifies "import urls" which results in ImportError: No module named urls.

The bakery app does not have a urls.py and I was wondering which urls the app was referring to?

all the best
Ross

six.text_type fails to write some stuff

Error

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/repo/documents/management/commands/build.py", line 10, in handle
    super(Command, self).handle(*args, **options)
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/src/bakery/bakery/management/commands/build.py", line 109, in handle
    view().build_method()
  File "/home/ben/Code/datadesk/sites/documents.latimes.com/src/bakery/bakery/views.py", line 89, in build_queryset
    outfile.write(six.text_type(html))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 75580: ordinal not in range(128)

Do we want to add Cache-Control headers on our pages?

Needs further research, but this could be another big speed and cost improvement. Would need to make sure there are ways to invalidate the cache, and would want a relatively short one for news pages.

I imagine some static resources - images, css, js, could have farther future headers though.

What if you are building your site to be hosted in a subdirectory on a CDN? How do you prefix the URLs during builds?

This question came up this morning during a Twitter conversation with @aplayford.

Here's an initial idea I have. What if:

  • Bakery was expanded to include a set of context processors that would have to be added to the user's ``settings.py.
TEMPLATE_CONTEXT_PROCESSORS = (
 #... all the usual crap
 'bakery.context_processors.base_url',
 'bakery.context_processors.static_url',
)
  • Which would create new variables that could be used in each template that looked something like:
<html>
<head>
  <script src="{{ STATIC_URL }}jquery.js"></script>
<body>
  <a href="{{ BASE_URL }}{% url 'homepage' %}">Back to the homepage</a>
</body>
</html>
  • Then when the template was rendered, the context_processors would analyze the request object they receive and be able to substitute in different values in the baked files by drawing on values in settings.py like:
BUILD_BASE_URL = 'http://www.foobar.com/subdirectory/'
BUILD_STATIC_URL = 'http://www.foobar.com/static/subdirectory/'
  • I'm not sure how the context processor would know when to make the switch but I suspect it could work something like this one except it would sniff the request to verify if it came from the RequestFactory we use in our buildable views. If that doesn't already include a reliable flag to execute that test, we could expand the views to plant something on the request or in the context dictionary.

Crazy?

Should be some way to selectively rebuild/publish views

It can take a long time to rebuild some views, and often we know that only one view has changed. However, in order to publish just the one changed view, we still have to rebuild everything, since the build command blows away the build directory and the publish command deletes anything from the target bucket that's not currently in the build directory.

Either I'm missing something straightforward, or there needs to be some mechanism by which we can tell bakery to only build/sync a specific view/directory.

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.