From LAMP to DARC
October 19, 2005 § Leave a comment
Meet
its 21st-century cousin: DARC
CoreData
This is especially cool when
combined with microformats. Click [Read more] for a very rough
demo script. You can also download the DARCdemo source code.
10.4:
A.
Setup
“DARCedit”
between them
“Users” and “Events” panes
model view into its respective tab pane
test
C. Create
Project
1. From an appropriate
directory, type:
DARCdemo
2. From
DARCedit.app:
table
database)
3. Edit config/database.yml
(e.g., using TextMate)
sqlite3?ÊÊdbfile: db/darc.sql
“database”
4. Here’s where you’d edit
Apache to setup a fastcgi connection, but we’ll ignore that for
now.
D. Create
Objects
1. Create model objects
(note initial Capital)
2. Map to
CoreData’s weird naming scheme. In
app/models/{event,user}.rb,
add:
ZUSERS
“Z_PK”
3. Generate scaffold
code
User
overwrite stylesheet (‘Y’)
not
generate Edit/New scaffolds, due to unconventional primary key (fixed in
download)
4. Run project
&&
http://localhost:3000/users
view
ruby to stop (often not needed; just refresh
to pick up changes)
default) and will corrupt the
database
E. Add
Microformats
1. Patch
ActiveRecord to restore original column names
config/environment.rb
containing:
ActiveRecord::ConnectionAdapters::Column
/,’-‘)
end
2. Edit
app/views/users/list.rhtml
Change: <% for user in @users
%>\n<tr >
To: <% for user in @users %>\n<tr
class=”vcard”>
Change: <td><%=h
user.send(column.name)
%></td>
To:
<td class=”<%= column.css_name
%>”><%=h
user.send(column.name)
%></td>
app/views/events/list.rhtml
using
“class=vevent”
3.
Edit
app/views/users/show.rhtml
vcard“>
# ‘vevent’ for events
a <dd> containing the class:
%>:</dt>
%>”><%=h
@user.send(column.name)
%></dd>
app/views/events/list.rhtml
using
@event
and
“class=vevent”
4.
Display in Firefox (if GreaseMonkey installed)
http://localhost:3000/users
graphic
graphic
Maps”
Book”
uncomment this line (near the end): #print
>>sys.stderr, structs
http://localhost:3000/users/show/1 > test.html
into Python then re-constituted as HTML
XML-like parsing out of ‘mere’ HTML
Leave a Reply