From the link: http://contentfilter.futuragts.com/wiki/doku.php?id=template_customization
The
HTML Template File is the most common way of deliver
ing a blocked page message to a user. It delivers a blocked page message quickly and cleanly to all web browsers, and does almost noth
ing else. It's just regular
HTML; there's no special syntax. You can edit it with any text editor.
When you
install
DansGuardian you should
at minimum modify the Block Page Template a little bit to include your own contact information. That way your users will know who and how to call if they have a problem. The rest of this document focuses on mak
ing more than just the m
inimum modifications to the Block Page Template.
(If you're very
interested
in Using Blocked Message Delivery for Other Purposes Too, you may need to deliver the blocked page message not this way via an
HTML Template but rather via
Method 2 (of 2): Using a CGI Program. That method also requires add
ing a web server. A
CGI program used to be the standard way to deliver a blocked page message, but has been superceded almost completely by the much simpler
HTML Block Page Template; that's why many custom
CGI programs for
DansGuardian can still be found on the web, but they're several years old.)
In your
dansguardian.conf file set the
reportinglevel = 3 as you see below.
# Web Access Denied Reporting (does not affect logging)
#
# -1 = log, but do not block - Stealth mode
# 0 = just say 'Access Denied'
# 1 = report why but not what denied phrase
# 2 = report fully
# 3 = use HTML template file (accessdeniedaddress ignored) - recommended
#
reportinglevel = 3
Usually the
HTML Template File should at least be personalized a little bit to better fit
into your environment. But what should you use as a base when personaliz
ing the
HTML Template?
The
HTML Template File that is provided when
DansGuardian is
installed may itself be fully adequate. Often the appropriate th
ing to do is to simply modify this supplied
HTML Template File. Sometimes though rather than modify
ing the supplied
HTML Template File you'll want to replace it with a version you obta
ined elsewhere that looks completely different. To see some alternative
HTML Template Files (and images), browse to
http://dansguardian.org/?page=extras and look under the head
ing “Report
ing script and gif replacements:”. (
CGI Program variants were much more common before the
HTML Template File option was available, so this list has not been updated nor expanded recently.)
To f
ind the
HTML template file, follow the values of the
languagedir and
language options
in your
dansguardian.conf. Sometimes
languagedir will be a subdirectory of your configuration directory (for example /etc/
dansguardian/languages), while other times it will be
in a “share” data directory.
In every case the file will be
named 'template.html'. Paths will of course be different on different systems; one typical path is /usr/local/etc/
dansguardian/languages/ukenglish/template.html, another is /etc/
dansguardian/languages/ukenglish/template.html, yet another is /usr/share/
dansguardian/languages/ukenglish/template.html.
Make a backup copy of the orig
inal
HTML Template File before modify
ing or replac
ing it.
As the
HTML Template is just regular
HTML, edit it the same way you'd edit any other webpage source file. Often you should simply edit the file with any text editor. (
HTML editors may or may not work well, as the comments and variable
information may confuse them or may become mangled although the
intention is to “save” them.)
Directly edit the pre-modified file that exists on the system, rather than any post-modified content that was sent to a web browser. The post-modified content will be specific to a particular blocked page, whereas what you want to edit is the more generic and flexible pre-modified template file.
View
intermediate versions of your modified file as often as you like by directly (not through
DansGuardian) us
ing any web browser until the general appearance is as you desire. Then, to see the results of substitut
ing the variable bits of
information, first guarantee that
DansGuardian is aware of your changes by execut
ing
dansguardian -g, and go to any end user computer and pretend to be any end user and try to access a website you know will be blocked so the blocked page will be shown
through DansGuardian to your web browser.
The
HTML File is just pla
in old
HTML with no particular restrictions; you can put anyth
ing
in here that web browsers understand. To give you more power, several variables can be filled
in by “text substitution” before the file is sent to a browser. You can use
these variable parameters to provide lots of functionality and enable different clever display options.
You can tell each user at several levels of detail exactly why the page they tried to access was banned. You can give yourself h
ints on which list file a restriction is
in so you can change it more easily. You can provide
click-to-acknowledge "bypass" functionality to some filter groups. And so forth. S
ince many options straddle the l
ine between “functionality” and “appearance”, they're also described below.
You may simply wish to personalize the blocked page. For example you should probably replace “YOUR ORG
NAME” with the
name of your specific
organization (“Humpty Dumpty Walls Co.”, or “Saguaro Elementary School”, or …) For another example, you may wish to change the reference to
DansGuardian to be just regular text rather than an active hyperl
ink.
Do
ing only this sort of change is very simple.
Or, you may wish to go further and make the blocked page more
informative to the user by rearrang
ing or customiz
ing the
information that's specific for each request. You can tell the user both
what was blocked and
why it was blocked, and if you wish also give the user a way to acknowledge the block then bypass it. There are quite a few potential bits of
information that can be substituted
in by
DansGuardian before the
HTML is sent to the web browser. Only simple text replacement without any knowledge of or attention to syntax is used; the
HTML Template File should be correct
HTML before the replacements and rema
in correct
HTML after the replacements.
These bits of
information can be used to tailor the blocked page to be a little more specific for each presentation to each user. The available bits of
information are described by comments
in the template file; you can also consult a list of
HTML File Parameters.
This sort of change is also straightforward, and is a good idea
in many cases.
You may wish to go even further and use
CSS to produce a fancier appearance (although the
increased complexity may not be worth it). The
HTML Template can (but need not) conta
in CSS, which will simply be passed through to the user's browser. The only pre-process
ing
DansGuardian does to the template before deliver
ing it to the user is simple text str
ing variable substitution.
F
inally, the
HTML Template can even (but usually doesn't) conta
in JavaScript, either for further tweak
ing appearance or for implement
ing some client-side process
ing. (You could even do variable substitution with
in your JavaScript code.)
Be wary of add
ing JavaScript to the
HTML Template though, not only is the
increased complexity often not warranted but it might not even work all the time. Browsers often restrict some JavaScript features. By us
ing JavaScript
in the
HTML Template, you could get
into a situation where someth
ing as basic as the “blocked page message” sometimes can't be delivered. You should probably add JavaScript to the
HTML Template only if you can guarantee that all web browsers will always have all the JavaScript functions you use enabled.
Even these sorts of more extensive changes are available to anyone that wrangles
HTML, and they do not require a web server.
Only add
ing media files (for example images, not just solid rectangles of color) as described below will require add
ing a web server.
If you wish to add extra content to the html template you will need to place that content (image, flash file etc.) on a web server. This can be on the same mach
ine as
DansGuardian is runn
ing, another server on your network or even a server on the
internet.
Edit the html template so the img is a full
URL. For Example:
img src="http://example.com/path/image.jpg"
The follow
ing won't work
img src="path/image.jpg"
If you don't follow the
instructions above you will get the follow
ing scenario. When you visit a blocked page, the block page doesn't
include the image/content and when you look at the properties of the object it shows the object location as:
http://denied url/image.jpg.
You can either create/manipulate an appropriate graphic, or use unchanged an exist
ing one.
Graphics can be
in any of the formats understood by web browsers, or to say the same th
ing with different words those formats that are commonly used on the web. The common web still graphic formats are .
GIF, .
JPG, and .
PNG. (
DansGuardian supports
any web still graphic format, which
in some cases also
includes other formats such as .
SVG.) You can create images with almost any image editor,
includ
ing high end commercial tools like Photoshop, high end Open Source Software tools like TheGIMP, and shareware or freeware tools like IrfanView. You may only need very few functions, such as “crop” “scale” and “edit palette”. If you have a suitable graphic but it's
in TIFF format so you just need to convert it, just a very simple shareware or freeware tool may be all you need.
You might be able to obta
in a graphic that's already suitable for use. Perhaps a school or company adm
in can supply one. Or perhaps you'll f
ind someth
ing suitable
in a clipart library. Or perhaps you can use some other
DansGuardian user's contribution. On the webpage
http://dansguardian.org/?page=extras look under the “Report
ing script and gif replacements” head
ing.