http://www.perlmonks.org?node_id=924344


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.

    regards,
    Luke Jefferson

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