Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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.


Comment on Re: Adding content blocks to a static website
Select or Download Code
Re^2: Adding content blocks to a static website
by blindluke (Beadle) 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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2014-07-10 05:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (199 votes), past polls