Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Adding content blocks to a static website

by moritz (Cardinal)
on Sep 06, 2011 at 09:42 UTC ( #924344=note: print w/replies, xml ) Need Help??

in reply to Adding content blocks to a static website

Another approach is to use server side includes. Instead of a <!-- PLACE CONTENT BELOW --> marker, you use <!--#include virtual="/your/newsfile.html" --> and place all the new content in $documentroot/your/newsfile.html. See the Apache SSI HowTo for more information.

That way the user just has to edit and upload one file.

If you'd rather stick with the placeholder approach, I'd recommend to either not do an in-place edit (create a modfiied copy), or mark both the start and end of the edit section.

For validation, HTML::StripScripts has a pretty good reputation (though I haven't used it myself).

What else should I be aware of?

Security. As always.

If you stick to the editing approach, you should be aware that it relies on uploading the whole HTML file. That means the user is able to replace it fully if he is malicious (maybe by extracting the server credentials from your script). It depends on your usage scenario if this is anactual problem.

Replies are listed 'Best First'.
Re^2: Adding content blocks to a static website
by blindluke (Hermit) on Sep 06, 2011 at 10:15 UTC

    Thank you. In my usage scenario, I can assume that the users aren't malicious (but they could do some harm, as they aren't very tech-savvy). But the server side includes approach you suggested looks far better than my initial aproach. This way, I can just add content at the beginning of the file, and the users cannot break the layout, even if they submit an empty page.

    If I'll have to code my own tool for this, I'll post the code in CUfP.

    Again, thank you for your suggestions.

    Luke Jefferson

      With enough monkeys banging on keyboards, cluelessness can be worse than maliciousness sometimes...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924344]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-05-27 01:41 GMT
Find Nodes?
    Voting Booth?