--> kmw (~youth@adsl-63-205-44-50.dsl.lsan03.pacbell.net) has joined #openacs Jim would you please set me in the right direction to correct the links from the main site page for attachments and notification and new-portal? kmw: do you have those packages mounted? I don't believe they have a user interface, at least not an index.html-like-thing so, if you click on those links, it's normal for them to say "url not found" kmw: what you might get into now is the templating system and use such knowledge to edit /web/$service/www/index.{tcl,adp} where $service is the name of your service (examples from your server of possible values of $service: "learn" "caltek") kmw: would you wanna do something like that? (I'm thinking that maybe the "Congratulations" page wasn't what you had in mind as a front page for your site?) ok I've printed some of the docs for the design guide portion of the templating system kmw: cool... it's a good possibility you want to familiarize yourself with tcl? if not already that is... I know you had an early acs or openacs, both of which had tcl available as a quick scripting language yes I'm very interested in learning tcl ok... Little Tiny Introduction To A Little Tiny Piece Of TCL either on your machine at home... or else on the vserver... see if you have a program called tclsh I did the tclsh at the command line and it gave me % ok, that's the tcl prompt... so i figure it's there and running now. try these commands: set this_variable "foof" puts $this_variable ok I did those two commands kmw: the second command should have printed "foof" (if I remember the print command :) and yes I know about and have read parts of the tcl for for web nerds....and yes it did print "foof" ok, now: put yourself in the documentor's seat... I'm logging this file...is that what you mean? if you were to go about explaining those lines to the next programmer, what would you say? ok (note!! the "next programmer" could be -you yourself- six months from now!) programmers forget everything they ever learned from time to time... it's a law :) I'd say the first line (set this_variable "foof") creates a variable field and places foof in that variable so, what would you put in this "time capsule"? yes, good! jim: i was going to say something, but I forgot what it was... and then the puts $this_variable prints it. davb: umm, what was your irc nick again?? :) the stored content of the variable "this_variable" More Advanced (by One Single and Simple Step) interesting you should quote the name of the variable... why because: tcl is capable of using variable names which are themselves values of variables set this_variables_name "this_variable" not sure I understand fully puts $this_variables_name oh I get it. which itself is a variable into the variable. set $this_variables_name "hmm, where does this text end up??" puts $this_variables_namne oops puts $this_variables_name puts $this_variable set $this_variables_name "hmm, where does this text end up??" puts $this_variables_name well, you want to put that in your tcl shell window :) I'm typying in the wrong window just a minute (the reasons I'm going in this direction... - you suggested the direction by quoting the variable name - I respond by showing the significance of quoting - Wanted to drive home the point that $name is the -value- of the variable; name is the -name- of the variable) by quoting a variable it can be included as a variable in other variables? yes, kinda works like a referral person X looks for a job at place A THe manager at A says: Hmm, X, looks like you'd be able to do job I... yaknow, place B is looking for someone that can do job I... I have a buddy at B, HERE IS HIS PHONE NUMBER (the all-caps passage is the "reference") ok the value contained is reference by $variable and varialbe is just the name to refer to the variable. yes... you'll use that occasionally... it's important to see that possibility of expression in this language ok How To Use Simple Variable Substitution in OpenACS Templating 1. From The Designer's Perspective (or, USING a data source) now... you know how to alter the contents of a variable (set name value) and yes you know how to refer to a variable in TCL $name another example of this same concept... acs templating system can use values of TCL variables ok let's create an example... great! lessee... can we work on practical pages that I need to do anyway? given that neither learn nor caltek has a customized front page... yes yes yes let's muck around with that :) good idea exactly what i need to do. would you like to edit the front page first, or create a new page for now? edit the front page. either way, ssh to (your server) as nsadmin ok I'm there. ok, remember where the learn server files are located? (where were you when you did the cvs checkouts) I think it's /web/(my service) yes, exactly i'm there the main pageroot for the learn server is /web/(your service)/www i'm there default-master.tcl ok, notice lots of files that start with "index"... 5 of them yes... only 1 .tcl some of those are relative to database functionality ok the actual template is two files: index.tcl index.adp ok the basic idea is this: index.adp is where the augmented html stuff goes (augmented, that is, by the extra tags in the templating system) ok you said you printed the designer's guide? (http://(your server)/doc/acs-templating/designer-guide.html) yes I have it here now. take a look at your printout and see how to form a reference to a TCL variable I do not see form a reference to a TCL variable on this page ok... do you see anything whose words might suggest something similar? embed a dynamic variable in a templte repeat a template section for each object that first one sounds like the one var is the word that they link to the details page Simple variable are referenced bysurrounding the variables named first_name and last_name and substitute ther values in the output so, what do you have to do to the name of a TCL variable to get the .adp to interpret it by replacing it with the value? surrounding? with what? put them in quotes quotes? no... look again :) variable name sith the at signs or @ yes! so... say I have a tcl variable called var oh it quoted "commercial at" ok how would I have the templating system replace that variable (called var) with its value? then we reference it in a .adp file by @var@ YES! this is the simplest example of a "data source"... Aside: About Data Sources, and Separating Programmer and Designer in all data sources, you write TCL code to "supply" the value of the source (which goes in the .tcl part of the template)... and you write various forms in the .adp part of the template to -use- the data source reason for separating this way: the programmer can be just a programmer, and leave graphics to the designer... wow that's great! and the graphics designer/html coder can be just that, having to learn a handful of tags while leaving the programming aspect (technical details of forming or creating data sources) to the programmer the programmer stays -away- from how the page will look and gives the data to the graphic designer who -decides- how that data is to look on the page specifically... the programmer writes the .tcl (and also includes a "contract" of data sources) that's what the contract module is about? the graphic designer writes the .adp (and looks at the programmer's contract to see what data sources are available and what they are) no, acs-service-contract is for something else I haven't figured it out all the way myself End of aside. Now, put on your Graphic Designer hat! kmw: ok, you're now a designer... and you see in the contract (-properties section) this: time_of_day : onevalue hey the concept is heavy and it confirms why tcl is a good graphical UI. where is the contract...in the .tcl file? this means time_of_day is available to the .adp as @time_of_day@ the contract would be there, yes... at the top... (thing is... we haven't yet put the variable there :) ok I'm in the index.tcl file and it has ad_page_contract I need to get back to using emacs use any editor you want we're going to start with the .adp first ok It has at the top we're -pretending- you (with your designer hat on) see: time_of_day : onevalue this refers to a template... can I add it. here. ?? yes, it is itself a template, and it uses also, a master template let me make that statement once more yes, index.adp is itself a template, and index.adp uses also, a master template got it. sometimes you feed values to the master but we're just going to put stuff in the index.adp template does the have some lines after? no OK... have you noticed most acs pages have a header, a horiz rule, the content, anothe horiz rule and a signature? at least I do not think they are param it says @system_name@ kind of noticed that. property, yes, that's the name I was thinking of it has two lines with that tag those are examples of how to feed values into the master template ok, what's the next thing after that? so it lists the master and then it feeds variables into the master templete that it's loading? yes, and the master template then does anything it wants with those values Congratulations. then it starts a table after that. ok, now, make it look like this: Congratulations. The time of day is @time_of_day@. that's an example of the designer using the "time_of_day : onevalue" contract item and also put the : onevalue" and contract item??? no, make the .adp look exactly as I said earlier just this: Congratulations. The time of day is @time_of_day@. ok, if you did that part, save the file ok it saved the index.adp file How To Use Simple Variable Substitution in OpenACS Templating 2. From The Programmer's Perspective (or, CREATING/ESTABLISHING a data source) (right now your index page is broke... we'll fix it now...) now go check, right? nono it's not ready yet because: the data source is not created or contracted ok i see that. it should have given you this long error message, the jist of which is "I don't even know the time_of_day" essentially, we're using something like a mailbox that hasn't been built yet i reloaded the page that already has me logged in so who knows.... so there's no place to store time_of_day yet but now, let's make one so now do i open the .tcl file? yes oh one moment it gave me cannot open file for saving... hi candy I'm not logged in as nsadmin i'll save it to another file and then copy it over once I login as nsadmin ok sounds like a potential time-saving plan, whose premise is "I don wanna type this thing again!" ok i've changed it and now I'm in the index.tcl file. ok, now, do you see other data sources listed in the contract? I'm looking I see properties with system_name:onevalue I see $user_id == 0 there we go, yes, this is a section of the contract called the properties section so first, you should add a line in the properties section it lists about 7 of them what you're adding should be lined up with theirs on the left, and should read: time_of_day : onevalue does it matter where in the properties and it already has 12 of them not 7 shouldn't matter which of the (13?) it is howbout putting it first or last... it';s last so you can get rid of it when you didn't want it :) ok... now, you want to get totally outside the contract... I do want it. I will edit out some of the others though ok I figure the } closes it. now, put this: set time_of_day "the ONE thing Natalie Portman forgot to give me yesterday" once you save that, try reloading the page done ok you should get the time of day in really big letters :) (why is it really big?) I get a request error can't read "time_of_day":... where did you put the set? oh I had not saved the .tcl fine...it's big because it's in a set of

tags. I'll fix it, now. :) you got it try it now. :) it works! End Of Simple Variable Substitution In OpenACS now how do I put the actual time in there? the idea behind this, is a programmer who knows tcl or is learning it would be the one to edit the .tcl, and the designer who for all intents and purposes doesn't want to know what the programmers do, or learn TCL or SQL this is a very good way to learn. I have a designer that is like that. I spoke to him for over and hour, today. he gave up on oacs last year because it was too complicated. he won't need to know any of this stuff :) otoh, he can learn if he chooses to get back on the horse but now he will give it another chance so I will walk him through it. all he will need, is the extra tags, and how to read the contract, and what tag to use with what kind of data source before we get to actual time... ok I want to point you to a few different places you should read at this point ok also I want to know what I should put in attachments and notifications...not sure I understand why the are on the main site. plus the new-portal link doesn't go where it should...I'm wondering of the permissions have something to do with that. then there's figureing out how people can be a dotLRN user once they become a user. without me having to add them as a dotLRN user. one by one. you guys have done alot, Ken I am heading back to the office in 10 minutes great! see what headset she is using, please. first, http://(your server)/doc/acs-templating/tagref/variable.html read thru that... here's some more places to look at: . http://(your server)/doc/acs-templating/demo look at the very first demo ("simple variable substitution") (there are four things to look at: what the tcl code looks like, what the adp template looks like, the combined form of the template that is finally interpreted, and lastly, the resulting page ) I have the first one printed out and the second one as well, I think I'll check oh the second one is the demo I understand the first 2 and the last one but where will I find the combined form? you won't, generally... it shows you that so you know what that internal form looks like oh I see it in the table of links from the demo table...that's neat. It should be link to from an obvious place in the docs. yes, if you look at the first page of the acs templating docs (from /doc), you'll see it at the bottom this Sample demo page is great. the demos show what can be done with the templating system and also give examples of how Using A Multi-Row Data Source To Capture And Display An SQL Query Result 1. From The Programmer's Perspective (Making The Data Source Available) next... you understand what an sql table is? I think so. it's like a spreadsheet look at it like a specially set up spreadsheet (yep :) with one record per row right, and one column per column :) each column is a named item of data one column per field or variable yes, that's right let's unbreak the page a bit... sounds good to me. html comments look like: Yes less than bash so now, comment out the part where we added the time of day in the .adp the effect of that, the code will still all be in place but won't actually read that variable the whole thing or just the response. I figure the whole thing for now. yeah, just the thing we added do I need to do both the time_of)day:onevalue and the set part? or just the set part? no, you can leave both of those I'm talking about -just- in the .adp I must be in the .tcl file. (comments in .tcl look like: # comment) ok I did it..I better check it. ok it's back to the way it was. "I better check it" YES. EVERY time. that goes in my "practice what I preach" file :) I've learn to do that from all of the html stuff I've done. now, we're going to try to get rows from a database table fantastic.... AND we're going to separate it, just like before, into roles of designer and programmer can we do it with a form? we're going to start with programmer first makes it easier to understand. ok I was thinking we'd jsut do a simple query first fine with me before we go forward, we've seen a tiny little bit of TCL, and actually used everything we saw it's time to start you with studying "TCL for Web Nerds" for the next week or so http://philip.greenspun.com/books/tcl great! you know where to get it? I've read some of it before so it should go pretty quick ok... yes I do. good. cool :) Properties Of Languages (Means Of Combination, Means Of Abstraction) so, as far as the TCL for web nerds thing, that will give you some ideas, rules, language elements and especially means of combining right. I'm looking at the website now. "means of combining" is, "how do I take the little primitive things and build bigger things from the pieces?" ok combine and resuse reuse something else that we did deal with today, is "means of abstraction" was that the variable of variables? which is, how do I take things (things that are primitive OR things I have built into bigger things) and giving them names... abstraction so that's what that means. after you give something a name, you can use it exactly as if it's always and forever been part of the language wow so... if you take "means of combination" (the ability to build big things out of smaller things) and "means of abstraction" together, you come up with a system that is wholly extendable take that in reverse.. if someone tells you that their favorite language is really cool... you can ask: "Why?? Tell me the means of combination available in the language! (How can I build things?) Tell me the means of abstraction! (How can I name things?)" I like these concepts. I'm trying to apply them to other things. like compreshion and art compression and art relating to abstraction and combining Look at Escher... he did a lot of repetitive pieces right or even dali or background images. in many things he did, the next piece is the current piece after applying some steps of a process to it ic combining and abstraction..it's good to understand what they mean yes in the context of what we are doing. (that part of this was taken almost directly from a lecture I saw from a video) ahh... which was a guess of appropriate SQL syntax. ok... kmw: edit that index.tcl ok in the contract, put this into the properties section: user_attributes : multirow somebody said multirow was a db_multirow. got that part? ok I added it ok, cool... * GEM catches up and wishes that he had enough brain to have actually read through the tutorial http://openacs.org/wp/display/491/ -oacs-chump/#openacs- A: http://openacs.org/wp/display/491/ from GEM A:|Skeletal "What to do after you have installed OACS" guide -oacs-chump/#openacs- titled item A when the designer reads that, he says: "Oh, that means I can put something like ' ..... ' in my .adp file!" ok a multirow data source is simply a holding area for something that's the same shape as an sql table i get it. kmw: do you know about the blog of this channel? is that what davb has on his site? I just put the URL for my "what to do after COngratulations" presentation there for everyone to see :-) yes, at http://www.thedesignexperience.org/openacs/ircblog/index.html is that the same one that's on the openacs.org/wp/display/491? Yes, it is I'm there now. I just put it where you can find it without me being around thanks. It is just beginning, now. I should steal things that Jim has been telling you to improve it GEM: the transcript of the leading-up-to-congratulations page is available too :) it will be good to work with Jim and we can add to it. Jim: I was hoping so look at 12.155.172.152/files Anyone want to collaborate with me on the presentation? not me for awhile at least... I dumpped many units on myself yesterday :) I'm tempted to try...I can at least work through and add things that I can. kmw: ok, what I want here, is for the database to pass me back first name and last name of each user ok that information happens to be in the persons table ok user table? that is, the way the aD people set it up, I read about the party table as well. they split up the original acs-3 users/groups setup it make sense to me why the did it. into users, groups, parties, persons and at least one more that I'm forgetting it adds another level of abstration...did I say that right? abstraction...if I can spell it right. yes, and also offers different means of combination that may or may not have been available before ok but for now, we're just interested in first and last name... I think the query goes like this: select first_names, last_name from persons ok where do I go to do that? that will give us every row in persons, but only give the first_names and last_name field in the same /web/(my server)/www folder? kmw: we're going to put that in the index.tcl file ok I'll open it, now. but tcl doesnt know sql... so we have to do something after to have tcl ask postgres to run this query it is open I last added the user_attributes:multirow ok in your browser, go to /api-doc (on any server you have rights to see that) i'm there. you're looking to search for the aD TCL proc called db_multirow read that description... and I'll be back in a few I'll be back in a few minutes.... ok Jim I read the db_multirow (public) document so I know a bit more about what it does..think I'm ready for a practical example, now How To Read Command Line Syntax Specifications (simple; maybe not complete) ok, see those things enclosed in brackets? this aurguments and options? ues yes usage: exactly... brackets means that part is optional (or, more definitively, "can appear either once or not at all") ok so, what is the first thing in db_multirow that -has- to be there? column rownumber the are automatic no... look in the usage statement [ -local] that's enclosed in brackets, so it doesn't have to be there... ok var_name yes :) var_name: 1 we want db_multirow to dump its results into the variable we named earlier, in the contract what name is that? user_attributes yes! so far, our statement reads: db_multirow user_attributes ok what is the next necessary part? then we need statement-name yes... here, we can be sorta arbitrary... the statement_name is used if the query is different between oracle and postgres (if that were the case, then we'd store two different versions in these other files that also start with index) ok but the query we have so far is very simple, and it does work with both ok but we should give our statement a name... we can call it get_user_attribs and so, our statement so far is db_multirow user_attributes get_user_attribs so now we have db_multirow user_attributes get_user_attribe so far, you can clearly see that there are three things in this statement the command name, the variable name and the statement name now one or two more things...ic sql and code_block ok, the sql we defined that earlier... we were going to use select first_names, last_name from persons ok A Means Of Combination In TCL: a TCL list (look at what I just typed... can you easily tell my narration from the sql query?) and the code_block? we're not going to supply a code block just because I'm following along on the printed sheet ahh :) reason we might supply a code block: if we would do some special calculation that happens every row, or if we want the ability to knock out rows ok but all we want to do is put all the data from the query into this holding area (which we are calling user_attributes) ok we defined that earlier... we were going to use select first_names, last_name from persons that's the first_name and last_name, right? (look at what I just typed... can you easily tell my narration from the sql query?) kinda you can because you quickly understand english... right. it's in English you probably have seen the word select before, too not sure what you are referring to. the word select so you figure the query probably starts from the word select and goes to the end of the line I typed we were going to use select first_names, last_name from persons yes TCL doesn't understand english :) TCL has no way of discerning narration from active items ok notice when you look at the page that describes db_multirow, that the parameter called sql looks like -one- entity yes consider the following possible completion of our statement: db_multirow user_attributes get_user_attribs select first_names, last_name from persons ok here's what TCL is going to think: user_attributes is the variable name get_user_attribs is the name of the database statement select is the sql (umm...) first_names, is the code block ERROR: extra garbage at the end: "last_name from persons" ic so, we need a means of combination ok we need to make select first_names, last_name from persons look like -one- thing will quotes do it? (instead of 5 things) Yes, it will. but so also will {} curley brakets? yep makes it -one- list so, instead of the FIVE words select first_names, last_name from persons we will have the ONE list {select first_names, last_name from persons} so, our completed statement now reads: db_multirow user_attributes get_user_attribs {select first_names, last_name from persons} db_multirow now sees THREE arguments (not seven) or so we have 3 objects in the statement right! go ahead and put that in there, in a similar place you put the set from before (outside of the ad_page_contract) ok the programmer is done with this data source :) now, the designer can use it (save the .tcl, take off your programmer hat, put on your graphic designer hat, and open index.adp) Using A Multi-Row Data Source To Capture And Display An SQL Query Result 2. From The Designer's Perspective (Deciding How The Data Will Look) ok pick a spot in the page, howbout right after the commented-out section that displayed the time_of_day? ok before or after the
line? remember you ran into a phrase in the docs that said "repeat a section of template for each object"? kinda that's what (repeated section) does ok but it sequences through the ROWS... the repeated section is repeated one time for each row in the multirow data source ok...i get that let's try a first cut of rendering your user names... ok in the place you have chosen, put this: @user_attributes.first_names@ @user_attributes.last_name@ or, let's try a -really- first cut... (make it look not too good ;) @user_attributes.first_names@@user_attributes.last_name@ that's what I thought...what's the difference between the two times you typed it in above? @user_attributes.first_names@@user_attributes.last_name@ kmw: I figure a first cut might involve trying no spaces first i broke it at the @@ ok, save the file and let's see if it works :) ok done view the page, tell me what you see it put our names in there. lemme add a few more users... actually, I'll hold off on that for now... is there anything wrong with the listing you see? or maybe more than one thing? [Note to reader: If you are now following along by actually doing the examples, please view the resulting page, and form opinions based on what you see, then continue from here] not sure what you are talking about. (remember two things: you're the graphic designer... you have all these -standard- html tags you can use...) the listing...yes what do you see? they are not seperated by commas or spaces commas? ok... put a comma right at the end, just before ok done ok, I see the commas now... ok, next... put the word 'start' before and put the word 'end' after tiple> done ok, I see the start... and end so, notice you can put things that do not repeat before and after the repeating section ok can you think of html tags that are similar to that? so that it loops through no I can't think right now. oh, uhoh :) toomuchinfo? from several sides at once. i'm multi tasking ahh but you are priority so you have the main pipe I try to respond quickly can you think of a set of standard html tags that have one beginning, possibly repeating in the middle and one ending tag? table yes :) that's one, can you think of another? howbout ul and li? or ol and li? list yes yes yes what should i put? so... notice however, that you have -successfully- rendered the output of an sql table! (maybe it doesn't look good/cool/the way you want, but you got the data from the table on the web page. -big- success. you used templating to display an HTML table.) exactly I feel empowered... so will your graphic designer you already did one thing successfully... but now, we will assume/pretend you're not satisfied with the look, and you want to try a different look replace the word start with
    replace the word end with
put
  • right after ldone look now :) refresh it now. replace
      with
        replace
    with ahh, no more comma done bullets ok, cool replace
      with replace with
      First NameLast Name
      replace
    • @user_attributes.first_names@ @user_attributes.last_name@ with @user_attributes.first_names@@user_attributes.last_name@ done ok... replace with
      ok that gives you a few ideas... End of Using A Multi-Row Data Source To Capture And Display An SQL Query Result At this point, we have seen two of the approximately 14 extra tags that the OpenACS Templating System introduces to the set of plain, standard HTML for use in .adp files. See demos of the others in http://(your server)/doc/acs-templating/demo/ which will also show how they achieved the result you see. In addition to the result, you can get: the HTML fragment that goes in the template, the TCL code that produces the data sources rendered by the template, and the raw code produced for running the template.