Compiled Websites with Plone, Django, Xapian and SSI
-
Upload
wojciech-lichota -
Category
Technology
-
view
1.520 -
download
0
description
Transcript of Compiled Websites with Plone, Django, Xapian and SSI
"
Compiled Websites with Plone, Django and SSI
Łukasz Langa"Wojciech Lichota"
Agenda
Reasoning
Plone and Static Deployment
Django and SSI
Search (Xapian)
Reasoning
Security solutions requiring 100% guarantee that the content cannot be edited from the Web
Performance dynamic Websites are resource hungry
Quality Assurance the ability to review complete content and functionality before every deployment
The Problem
Reasoning
Security front-end/back-end division
two-level authentication
Performance throwing hardware at the problem
caching
Quality Assurance dedicated workflow environments
test instances
Existing Approaches
Reasoning The Solution
Website compilation
The Solution Static Deployment
Convert all Website resources to static files HTML
CSS
JS
attachments
media
Deploy the HTML on a traditional Web server ✓ orders of magnitude
better performance
✓ incredibly simple scalability
✓ server-agnostic quality assurance
Static Deployment with external tools
Examples: HTTrack wget -‐-‐mirror
✓ out-of-the-box solution
✗ weak control of output
✗ slow
Static Deployment with internal tools
Solutions for Plone: enpraxis.staticsite stxnext.staticdeployment
✓ much faster than external solutions
✓ fully configurable
✓ easy to customize
✗ needs integration with website
Static Deployment stxnext.staticdeployment
Open-Source (ZPL)
two parts of configuration basic: for content editors
advanced: for administrators
incremental
content transformations
pluggable
integration with Xapian
stxnext.staticdeployment
stxnext.staticdeployment
Static Deployment ...too static!
User profiles
Commenting
User communication
Search
We need something more sophisticated!
The Solution Plone + Static
Deployment
Django for: User profiles
Commenting
User communication
Xapian for search
Compiled Website
The Solution How to glue components together?
client-side approach: JavaScript ✓ simple implementation
✗ many requests
✗ page flickering
server-side approach: Apache SSI
✓ single request
✓ transparent to the user
✗ skin customization Compiled Website
The Glue Apache mod_include (SSI)
HTML preprocessor provided by Apache httpd at least since version 1.3
Processing controlled by SGML comments
Basically enables: conditional text
inclusion of other files
inclusion of programs
printing/setting environment variables
Apache m
od_include
A basic SSI element:
<!-‐-‐#element attribute=value attribute=value ... -‐-‐>
Typical elements: #include #echo #exec #set #if / #elif / #else / #endif
no whitespace
Apache m
od_include
Enabling SSI in the server configuration:
... LoadModule include_module modules/mod_include.so ... AddType text/html .html AddOutputFilter INCLUDES .html ... Options +Includes
Examples of basic directives: current date on the server
<!-‐-‐#echo var="DATE_LOCAL" -‐-‐>
file modification date Last modified: <!-‐-‐#flastmod file="index.html" -‐-‐>
inclusion of results from a dynamic application <!-‐-‐#include virtual="/app-‐comments/thread/3/" -‐-‐>
executing local commands <!-‐-‐#exec cmd="uptime" -‐-‐>
Apache m
od_include
Inclusion of results from a dynamic application <!-‐-‐#include virtual="/app-‐comments/thread/3/" -‐-‐>
How to specify an external application to be available from /app-‐comments ?
RewriteEngine on RewriteRule ^/app-‐comments/(.*)$ http://localhost:8686/$1 [L,P]
What if the external application is not available? Apache includes the following message by default:
[an error occurred while processing this directive]
This can be customized in server configuration by:
SSIErrorMsg "<!-‐-‐ Error -‐-‐>”
The default message can be overriden in HTML by:
<!-‐-‐#config errmsg=”Custom message" -‐-‐>
Gotchas Gluing Django with SSI
context-specific arguments need to be GET params by default Django uses
URL parts
redirect after POST requests POST requests cannot
render anything
form validation requires additional plumbing
Website templating in two places Plone skin
Django templates
Gotchas Apache httpd
Apache is slow...
Gotchas Apache httpd
Apache is slow... NOT! mpm_prefork is evil
use mpm_worker
any experience with mpm_event?
Advantages of Apache: largest install base
maturity measured in years
the best WSGI module available (mod_wsgi)
What about search? Xapian with SSI
python-‐xapian binding
Ranked search
Suggests spelling corrections
no Polish stemming
"
Compiled Websites Guest Starring
Django Pony
www.djangopony.com @djangopony
Questions?