Greetings, esteemed monks!

Update: The OS is Linux RedHat 3 soon to be RH4, and the web server is Apache. Users will access the app through IE and/or Firefox.

I'll be writing a system that will provide web-based whiteboard facilities to a company in the case of a disruption. (Yes, it would make a perfectly good system in normal operations, but that's not what they want it for.) The business unit, called a Division, is broken up into seven sections. There will be one whiteboard per section plus one "overall Division" whiteboard.

The whiteboards will have two levels: Division-wide and then the section-specific pages. Each whiteboard will have a "General Note," presumably to be set by the boss, and then one row per person, including one under the boss' name. There are three fields per record: name, message, and a string representing who last edited the previous field (as determined by the web server), and when. Everyone in each section can edit everything on that section's whiteboard, but only members of that section's unix security group can edit that section's whiteboard at all.

The "main" whiteboard will have an row for each section which will be the "General Note" from the whiteboard of that section. Then there will be a "General General Note" on the main whiteboard which is basically a "message from the director," rally the troops kind of thing, I suppose.

So anyway each whiteboard (which I think itself will be an html table in a page with a cool stylesheet) should be editable only by members of the appropriate section, by membership of unix security groups. Anyone on the network should be able to view any whiteboard.

So far I am thinking that there will be one perl script which is the "editor" of any and all of the whiteboards. The data itself will be stored in csv files (I tried XML and it's just too clumsy for me compared to Text::CSV::Simple). Anyway the csv text files themselves have to be read/writable by section members only, AND r/w by the ID the web server runs under. That's the security hole right now, but we're working on it. In "phase II," we may introduce a "private area" on each whiteboard which is only viewable(as well as editable) by section members. However unlike the main portion where each section member gets their own field, this would be a shared field and, as my Director said, function as a chat room.

Update: please see the reply below for the current code. Thoughts and suggestions appreciated.

_________________________________________________________________________________

I like computer programming because it's like Legos for the mind.

  • Comment on (RFC) A CGI whiteboard editing script for emergencies UPDATED WITH CODE 9/26/06

Replies are listed 'Best First'.
Re: (RFC) A CGI whiteboard editing script for emergencies
by Fletch (Bishop) on Aug 26, 2006 at 14:01 UTC

    Sounds like you're over reengineering reimplementing a wiki.

      Hmmm, a wiki. We do have Twiki, but I don't think there's anyone here (that I know of) who knows how to set up the permissions properly.

      Also, since the idea is that it will work in an emergency, it has to be as simple as possible. If I write a CGI script, only two machines have to be up for it to work. Use a databse and that number goes up by 50%. Not sure about the Wiki. Also have to check if we have the DBI::* modules installed. Thanks again for the replies. ++

      Terrence

      _________________________________________________________________________________

      I like computer programming because it's like Legos for the mind.

        My employer was using swiki for awhile, which does not use a database backend - instead it uses xml files. The idea was to keep it as simple as possible and remove dependencies and simplify administration. Worked well until the machine went down because of a runaway script and the XML files were mangled somehow. We have since switched to using a different wiki, with a database backend.

        Issues like file/record locking and the ability to gracefully handle an unexpected shutdown are things that databases excel at. I would recommend taking advantage of this.

        If the DBI modules are not installed on the server you can always install them to a local directory and define the PERL5LIB environment variable.

        As for reducing the number of machines involved, why not run the database on the same machine as the web service?

Re: (RFC) A CGI whiteboard editing script for emergencies
by imp (Priest) on Aug 26, 2006 at 03:03 UTC
    Sounds like you just need a place to store data, a simple web interface, and a basic permissions structure.

    In my opinion you should use a database to store the information instead of text files. It's less work ultimately, and won't cause badness if two people save the same item at once.

    As for the web interface you should use a templating system instead of writing inline html. It's much cleaner and easier to maintain. Your needs sound fairly basic, so you can get away with using HTML::Template. You should be up and running with it in under 30 minutes, and will never write inline html again. If you're adventurous then Template Toolkit is a more robust option.

    As for the perl code to control everything there are a number of frameworks for encapsulating common design patterns. For example, CGI::Application provides the common dispatch script behaviour.

Re: (RFC) A CGI whiteboard editing script for emergencies
by OfficeLinebacker (Chaplain) on Aug 26, 2006 at 02:50 UTC
    So I've been thinking up on some of the details and one thing is that we need to have an area for the text files and the html that is nor the same directory structure where CGI scripts are enabled. So I am thinking that there will be a 'wb' directory, and each section will get a subdirectory. Each section subfolder will have two files: index.html and sectioninfo.txt. The index.html is just so the web address can be in the form

    www.whatever.com/Division1/wb/sectionmnemonic

    The creation of the Division whiteboard will key off of the subdirectory list in the 'wb' directory. So to add a new section or delete one, just create/delete a folder.

    So we're talking one script plus two files per section. Seven sections means 15 files for this system. not too bad, eh?

    _________________________________________________________________________________

    I like computer programming because it's like Legos for the mind.

Re: (RFC) A CGI whiteboard editing script for emergencies
by chargrill (Parson) on Aug 26, 2006 at 02:56 UTC

    Erm, I clicked too fast. What was your question?



    --chargrill
    $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}
      Basically, what do you think of the design? Of using text files vs. XML vs. a db?

      And imp, as for you, young man, I normally would probably take advantage of the postgres server that we have here, but a) admin is controlled by someone else and b) it introduces another dependency. The sql box doesn't have a great history of reliability or response to customer queries (get it? queries? huhuhuhuhuh). If this were for day-to-day use, yeah, I'd probably use a db. But files are just as easy to me now that I've used Text::CSV::Simple a few times and it's one less dependency on an externality when the proverbial excrement hits the fan. I guess delevopment time also factors in.

      _________________________________________________________________________________

      I like computer programming because it's like Legos for the mind.

        Basically, what do you think of the design? Of using text files vs. XML vs. a db?
        Wrap it all up behind DBI as a general interface layer and you'll be able to trivially (just change the DSN) switch between them ... so, for example, you can start with text files because they're easy to create .. or start with the db and if there're admin issues, switch to text or xml..
        See DBD::CSV, DBD::AnyData, DBD::Pg, etc ..

        (additionally consider putting Class::DBI or DBIx::Class or some other db abstraction layer on top of DBI)
Re: (RFC) A CGI whiteboard editing script for emergencies
by OfficeLinebacker (Chaplain) on Sep 01, 2006 at 13:58 UTC
    Greetings, esteemed monks!

    UPDATE: So I've consulted with the guy who runs out web server and he recommended that the whole thing be CGI--the displayer and the editor. That's cool by me. I may put all the data into one big file (now that starts calling for a true DB, big time, cos then the display page has to be able to pluck just the appropriate entries based on a combination of their choices and their default unix group). Anyway, been busy with busywork, you know stuff that isn't really that creative. But this is on priority.

    _________________________________________________________________________________

    I like computer programming because it's like Legos for the mind.

Re: (RFC) A CGI whiteboard editing script for emergencies
by OfficeLinebacker (Chaplain) on Sep 13, 2006 at 16:50 UTC
    Greetings, esteemed monks!

    So it turns out there is a PostgreSQL database that has tables that will allow me to extract a list of all user IDs, and real names that are members of any given group. From there I can do an `id -Gn` for the rest. I plan to store everything in a local SQLite database for editing and manipulation, and have a cron job that periodically syncs the databases, or more likely, looks for differences in the lists and notifies me.

    _________________________________________________________________________________

    I like computer programming because it's like Legos for the mind.

Re: (RFC) A CGI whiteboard editing script for emergencies UPDATED WITH CODE 9/26/06
by OfficeLinebacker (Chaplain) on Sep 26, 2006 at 13:49 UTC
    Greetings, esteemed monks!

    Here's what I have so far. We're going to test multiple simultaneous users today and then test with probably a few dozen users on Saturday.

    Some things in the comments and variable values may be inconsistent; I don't want to give too much away about where I work.

    Also, I used Perltidy to clean it up in the way I like. If the majority of commenters don't like the format, I can retidy it. Thanks!

    Terrence

    _________________________________________________________________________________

    I like computer programming because it's like Legos for the mind.

    Edited by planetscape - added readmore tags