Tomas
Tomas

Reputation: 340

How to modify and save html/css in server-side?

I'm new in this subject so this might be a silly question for most of you. I have a simple server which several users will access. If any of them change a CSS property of an element, the others should be able to see the change in real time.

Should I use something like node.js to perform this? How do I save the changes the users do?

The page would look something like this: http://stom89.dyndns.org/

Thanks!

Upvotes: 1

Views: 3845

Answers (3)

gabeio
gabeio

Reputation: 1310

I have been messing with this subject for sometime if I completely understand your question. I would suggest looking at python, ruby or node.js though I could not say which is the easiest to learn for you though I would suggest python and a comet server which could be ape and simply have the server push the updates to the users that are already on the site.

Edit: Suggestions for polling :: jQuery
http://api.jquery.com/jQuery.get/ for standard data retrieval which is about all you will need.

Upvotes: 1

ioannis
ioannis

Reputation: 337

I guess what you want to change in your CSS / html , are states. Like if a lamp is on/off? Then you need to save each state in a mySQL DB and just grab the data for each user. If you want it to look like realtime for online users, then use js(ajax) to sync data regularly.

Alternative way without a DB would be with files.

If you don't wanna use mysql for this, you can use files. I suggest using ini files. For more on how to read/write ini files, you can visit this question. It's super simple and you'll be able to have each variable in a nifty array.

What you need: A bit of PHP, a little bit of jQuery (or js), understanding of GET variables

I suggest you create 3 files.

index.php :
Your main page which is the client. Pulls info using get variables. You can use jQuery.get() for this.

getstate.php :
This is the file which will read the ini file and give you back the states for each device. Read them with jQuery.get() from index.php .

savestate.php:
This is the file which you'll send the new states to from index.php Example request: http://address.goes.here/savestate.php?bedroomlight=1&garagelight=0

Whats even more interesting is that ini files can be written/read easily by many programming languages so you can manipulate the data using your Raspberry Pi easily. (say someone turns of a light, a script polling state could change the ini file)

Upvotes: 2

Westwick
Westwick

Reputation: 2487

I think you would need to use a sql database and have a javascript to detect changes and update through AJAX. That's my best idea.

Upvotes: 2

Related Questions