Posts

Showing posts with the label static

Generate static html file from WordPress page

OK, Is your WordPress page rarely get updated, let's say once a day or a week. If so, you can use the following technique to reduce the load (queries) to the database especially in multisite deployment: Write a script to generate static content with updates from the database only once a day or a week. Then your users will access this static page instead of the heavy loading WordPress page with hundreds of database queries. 1. Create a wordpress template file wp_template.php (place it in your template root, e.g. /var/www/wordpress/wp-content/themes/mythemes/) which will get data from the database. For example: 2. Create a crontab to run this command every day at 1AM to generate the static html file in the web root: /usr/local/bin/blog_static_gen.sh: #! /bin/bash $ cd /var/www/wordpress/wp-content/themes/mythemes $ php wp_template.php > /var/www/wordpress/wp_template.html crontab: 0 1 * * * /usr/local/bin/blog_static_gen.sh 3. Then you can access the static co...

edx-platform - Error "...could not be found with..." when compiling assets

Yesterday, I got this error when trying to compile assets of our OpenEdX instance's Studio: with this command: ~/edx-platform: paver update_assets cms --settings=aws First, there was no file locates at themes/ourtheme/images/bg.png . Then what? I took a tour into the template directory and check the sass file at   /edx/app/edxapp/themes/unschool/static/sass/_ourthem.scss There were one variable which was defined with wrong url or didn't been used anymore in the template: $homepage-bg-image: url('../themes/ourtheme/images/bg.png'); So, I just comment out that var and run the compile assets command again. Everything's ok now.

Getting started with static files in Django

For the first time I worked with Django (v1.1), I had to do something like: adding the url pattern point to static directory of my project in the main urls.py file: ... (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes': False}), ... In the newest version of Django (1.5.1) which I'm using right now, all I have to do is: 1. Put  the static files in a static subdirectory of my apps ( myapp/static/ ) or list absolute path to static directories in # Additional locations of static files STATICFILES_DIRS = (     # Put strings here, like "/home/html/static" or "C:/www/django/static".     # Always use forward slashes, even on Windows.     # Don't forget to use absolute paths, not relative paths.     #~ '/home/projects/mystatics/', ) Django will serves your app static files by looking for them in those above directories.  2. Leave the main...