luca
luca

Reputation: 12601

How to setup a dynamic website with javascript only (no serverside)

Here's my problem: I want to build a website, mostly static but with some dynamic parts (a little blog for news, etc..). My webserver can only do static files (it's actually a public dropbox directory!) but I don't want to repeat the layout in every html page!

Now, I see two possible solutions here: either I create an index.htm page that emulates site navigation with javascript and AJAX or I create all the different html pages and then somehow import the layout bits with javascript..

From you I need ideas and suggestions on how to implement this, which libraries to use, or maybe there exists even something tailored exactly for what I need?

Thanks!!

Upvotes: 4

Views: 5787

Answers (5)

Jan
Jan

Reputation: 8131

You can use the Google Closure templates. It's one of the fastest and most versatile javascript templating solutions around.

Upvotes: 0

Jeff
Jeff

Reputation: 21892

Have you considered using publishing software on your computer to combine your content with a template, resulting in a set of static pages that you can then upload to the dropbox?

Some options in this regard come to mind:

To handle comments, you can use Disqus. It inserts a complete comment system into your site using just JavaScript.

Upvotes: 0

PleaseStand
PleaseStand

Reputation: 32052

jQuery allows you to easily load a section of one page into another page. I recommend loading common navigation sections into the different pages, rather than the other way around to avoid back/forward problems. Layout can be done with a separate CSS file rather than with tables to minimize the amount of repeated code. For the blog, you could put each blog entry in a separate file and load each section individually.

However, I would just use something already available. TiddlyWiki, for example, is a self-contained wiki that is all in one file. It's very customizable, and there's already a blog plug-in available for it. You can work on the site on your hard drive or USB drive, and then you can upload it to the web when done. There's nothing more to it.

Upvotes: 0

ceth
ceth

Reputation: 45285

Just another one way. You can generate static HTML in your computer and upload result to dropbox. Look at emacs muse.

Upvotes: 0

Chris Laplante
Chris Laplante

Reputation: 29658

I would define the site layout in your index.html file, and then use JavaScript and Ajax to load the actual content into a content div on the page. That way your content files (fetched by Ajax) will be more or less plain HTML, with CSS classes defined in index.html. Also, I wouldn't recommend building a blog in pure HTML and JavaScript. It wouldn't be very interactive; no comments, ratings, etc. You could store your blog content in XML and then fetch and display it with Ajax and JavaScript, however.

While on the subject of XML, you could implement all your site content in XML. You should also store the list of pages (for generating navigation) as XML.

Upvotes: 2

Related Questions