diff --git a/step3.html b/step3.html index ece76f4..ac28a8b 100644 --- a/step3.html +++ b/step3.html @@ -33,9 +33,9 @@
Adding some data is pretty simple. Ur/Web does some automatic table name generation. Looking inside the urblog database, there is one table: uw_Urblog_entry. Tables are named according to the modules they belong to (and module names are in turn defined by file names -- our entry table is defined inside a file called urblog.ur, which leads to an implied module Urblog). This separation is used by Ur/Web to achieve useful encapsulation of tables, such that one module cannot (inadvertantly or intentionally) interfere with tables that are owned by some other module. I added some test data like this:
-insert into uw_Urblog_entry (uw_id, uw_title, uw_created, uw_author, uw_body) +insert into uw_urblog_entry (uw_id, uw_title, uw_created, uw_author, uw_body) values (0, "This is a test entry", now(), "Gian", "This is a test entry. I hope you like it"); -insert into uw_Urblog_entry (uw_id, uw_title, uw_created, uw_author, uw_body) +insert into uw_urblog_entry (uw_id, uw_title, uw_created, uw_author, uw_body) values (1, "This is also a test entry", now(), "Gian", "This is yet another test entry. I hope you like it");@@ -85,7 +85,7 @@
-allow url http://expdev.net/urtutorial/step4/style.css +allow url http://expdev.net/urtutorial/step3/style.css rewrite style Urblog/blogEntry blogEntry database dbname=urblog sql urblog.sql diff --git a/step4.html b/step4.html index 33136fe..b5acc4b 100644 --- a/step4.html +++ b/step4.html @@ -80,6 +80,19 @@+urblog.ur
[...]
Since we added a new style.css url, we add a line allowing access to the url to our .urp file:
+ ++allow url http://expdev.net/urtutorial/step3/style.css +allow url http://expdev.net/urtutorial/step4/style.css +rewrite style Urblog/blogEntry blogEntry +database dbname=urblog +sql urblog.sql + +urblog ++ +
To ensure our new detail function visible to the outside world, so we add its signature to the signature definition:
@@ -108,6 +121,15 @@We also introduce a new style blogComment.
++[...] +style blogEntry + +style blogComment +[...] ++ +
Our comment function is pretty simple. The only thing we have to do is specify a type annotation -- Ur/Web can't always figure out the type of functions on its own. In this case we specify that our function is transaction xbody. This type (xbody) is that of XML that is suitable for inclusion within a body tag. The transaction, as before, indicates that this is part of a monad, and is therefore suitable for inclusion within other transactions (as all content that will be delivered to users must be).
@@ -137,7 +159,7 @@urblog.ur
urblog.urp
-We need to update our project file and style sheet (adding the rewrite for the new style declaration):
+We need to update our project file and style sheet (adding the rewrite for the new style declaration). Since our new stylesheet contains our old css, we can replace our original link (in the list function) with http://expdev.net/urtutorial/step4/style.css and shorten our .urp as shown:
allow url http://expdev.net/urtutorial/step4/style.css diff --git a/step5.html b/step5.html index a24979c..8e584f3 100644 --- a/step5.html +++ b/step5.html @@ -87,7 +87,7 @@-urblog.ur
[...]We also add a new style and add an appropriate rewrite for the style name.
+We also add a new style and add an appropriate rewrite for the style name. The style.css file can be found at http://expdev.net/urtutorial/step5/style.css. We can replace references to the old link in our .ur and .urp files with the current one, similarly to what we did at the end of step4.
Updating the database
@@ -114,7 +114,7 @@Updating the database
Putting it all together
-As ever, you can compile the application. Make sure you have at least one test blog entry you can work with in your database, and then you can test the application by going to:
+As ever, you can compile the application. Notice, since we added the sequence commentS, compiling updates our urblog.sql with a new uw_urblog_comments table. You'll need to create this table, possibly by wiping your current ones and reloading urblog.sql as shown earlier. Make sure you have at least one test blog entry you can work with in your database, and then you can test the application by going to:
http://localhost:8080/Urblog/list
diff --git a/step6.html b/step6.html index e6f9be9..b5d49e9 100644 --- a/step6.html +++ b/step6.html @@ -32,7 +32,7 @@Step 6
How does this differ from components parameterised on table structure, you might ask? Well, that's a reasonable way of thinking about some of what this metaprogramming enables, but in Ur/Web it goes further. We can use familiar programming constructs (e.g. map and fold) to compute new types from old ones. We can invoke appropriate display functions based upon the types of the fields in a row. This gives much of the same flexibility that dynamic web languages can provide; however, Ur/Web does it in a way that is statically checked at compile time.
-The Crud component is reasonably simple. We'll skip over most explanation of how it actually works, because you can divert back to that later. The component consists of two files -- a signature and an implementation.
+The Crud component is reasonably simple. We'll skip over the code and explanation of how it actually works, because you can divert back to that later. The component consists of two files -- a signature and an implementation. They can be found here.
urblog.urp