Re: [libdb-develop] Don't Look At This Demo
Status: Inactive
Brought to you by:
morbus
From: Morbus I. <mo...@di...> - 2004-02-19 15:54:35
|
>Note: on Safari at least, in general the text >rendering is coming across as rather ... large. Odd. Could you screenshot it for me? I've ONLY been testing the layout in Safari lately. Cross-browser stuff I always check the next day (being today <g>). >BTW, how are you designing the underlying code that lays out the form? >Would be nice to start with a system designed to be easily modified by >users. I'm no coder, but how about an xml template config file that >defines how each type of record would be presented? That way later on >it's easier to add stuff other than films. It's actually "just HTML" with movable snippets of "code you don't have to understand". http://cvs.sf.net/viewcvs.py/libdb/LibDB/ templates/default/en/add_film.html?rev=1.2&view=auto That's the URL for the source code of the "add_film.html" file, which is what's parsed when ?tmpl=add_film is sent to LibDB (going through the paths, this is the "add_film" file for the "en"glish version of the "default" "template". The name of the template and the language of the user is determined automatically by the internal code, so URLs need only to worry about the name of the file, passed via "tmpl="). As you can see, it's 99% HTML. Here's an explanation of the code snippets you do see. All non-HTML code is encased in delimiters: [$ # this is the starting delimiter of "code is coming" # this is where code goes. code can print HTML too. $] # this is the ending delimiter of "code is done!" The simplest piece of code is getting the value of a setting. The following line (well, something similar) is used to print out the little "0.1.0" thing in the footer of each page: my $ver = LibDB::Settings->get("app_version") As for other pieces of code, I've tried to keep them as "movable" as possible, with no regard for what sort of media we're adding. So, the following code, which displays the different "locations" where an item can live, is the same regardless of whether we're adding a movie, a book, a magazine, or what have you (note that I've included lots of whitespace and commenting here for your perusal: in the "add_film.html" file, it's just four lines): [$ # here's our delimiter. ie. "code is coming" # create an interface to the database, and # prepare a data structure ($results) to store # any results we receive. my $db = LibDB::DB->new; my $results; # connect to the database, and store a list # of all our possible locations into $results. # if this fails, we return an error message and # stop processing FOR THIS BLOCK OF CODE only. unless ($db->connect and ($results = $db->get_locations_types)) { $OUT .= '<p class="err">'.$db->error.'</p>'; return; } # if we're this far, then there were no database # errors, so we expect to have rows of results # stored in $results. we'll go through each result # and print out an HTML <option> tag for our <select>. foreach my $r (@$results) { $OUT .= "<option value=\"$r->{lt_id}\"> $r->{lt_name}</option>"; } $] # our ending delimiter. no more code. In your case, if you wanted to revise the "add_film.html" to be book specific, you could run through the following steps (assume, of course, that add_film.html would be a final version, and not what I'm currently working on): a) copy "add_film.html" to "add_book.html". b) change the HTML to reflect books, not film. c) there is no step three. There's no step three because you won't really have to change any of the database/template *code* (code meaning Perl, not HTML markup) to satisfy your needs. Ultimately, the distinction between "film" or "book" or "comic" happens in the interface only, and not in the underlying frameworks. Thoughts? -- Morbus Iff ( i put the demon back in codemonkey ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus |