-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathINSTALL.txt
58 lines (41 loc) · 1.87 KB
/
INSTALL.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Installation:
Using pip:
pip install django-stw
If you checked out from github:
python setup.py install
Configuration:
1. Add 'stw' to your INSTALLED_APPS tuple.
2. Define a SHRINK_THE_WEB dict in settings.py minimally containing:
SHRINK_THE_WEB = {
'stwaccesskeyid' : 'your STW access key id' - required',
}
where the dict keys match parameter names in the STW documentation:
https://shrinktheweb.com/uploads/PRO_Feature_Documentation.pdf
django-stw defines a key 'lang' for the SHRINK_THE_WEB dictionary that
can be passed along as a default to the preview tag. Alternately a 'lang'
keyword can be supplied in each template tag invocation. STW defaults it
to 'en'.
If you want to have the same settings for either tag on a site wide
basis you can specify additional STW URL parameters and values
in the settings.SHRINK_THE_WEB_DEFAULTS dictionary. Individual
template tags can then override the default values.
i.e.
SHRINK_THE_WEB = {
'stwaccesskeyid' : 'your STW access key id' - required',
'stwdelay' : 10, # wait 10 sec for page to load before STW captures image
'stwsize' : 'xlrg', # default to xlrg image size
}
then this template tag shortens the delay to 5 sec and adds the stwinside parameter,
the stwsize is taken from the defaults: 'xlrg':
{% stwimage "http://example.com/internalpage.html" "The author website" "stwdelay=5 stwinside=1" %}
Example Site:
The template directory contains a sample template that demonstrates more uses.
Add the template to your project's urls.py:
urlpatterns = [url(r'^stw/', include('stw.urls')),
# the rest of your urls
]
Start django server and visit http://localhost:8000/stw/ in your browser to view the page.
Tests:
The tests require the mock package (http://www.voidspace.org.uk/python/mock/mock.html):
pip install -r requirements-test.txt
They can be run without setting up a Django project via: python runtests.py