Jukebox/w3tpl: Difference between revisions
got title listing working |
updated script to work (at least somewhat) with latest w3tpl syntax |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=The Hypertwin Jukebox= | =The Hypertwin Jukebox Prototype= | ||
This was a prototype written in [[htyp:W3TPL|W3TPL]]; it allowed us to export files over the LAN, but the links were often broken. It is also rather slow, being written in a language being interpreted by a parser written in another interpreted language. I'm leaving it here as an example of working W3TPL code. | |||
<hide> | <hide> | ||
===================== | ===================== | ||
Line 6: | Line 6: | ||
===================== | ===================== | ||
<func GetArtists> | <func GetArtists> | ||
<for db=audioferret table="qryArtists_index" sort="name" | <for db=audioferret table="qryArtists_index" sort="name"> | ||
<let name=ar_name val="@row | <let name=ar_name val="@row.name" /> | ||
<let name=outFunc append> | <let name=outFunc append> | ||
* </let> | * </let> | ||
<let name=outFunc append vars>[{{fullurl:{{PAGENAME}}|artist=[$@row | <if comp=@row.id with=$doArtist> | ||
<let name=chosen_artist_name copy=ar_name /> | |||
<let name=outFunc append>'''</let> | |||
<let name=outFunc append copy=ar_name /> | |||
<let name=outFunc append>'''</let> | |||
</if><else> | |||
<let name=outFunc append vars>[{{fullurl:{{PAGENAME}}|artist=[$@row.id$]}} </let> | |||
<let name=outFunc append copy=ar_name /> | |||
<let name=outFunc append>]</let> | |||
</for> | </for> | ||
</func> | </func> | ||
Line 19: | Line 25: | ||
<let name=sqlFilt vars>idartist=</let> | <let name=sqlFilt vars>idartist=</let> | ||
<let name=sqlFilt append copy=doArtist /> | <let name=sqlFilt append copy=doArtist /> | ||
<for db=audioferret table="Albums" where=$sqlFilt sort="sort, name" | <for db=audioferret table="Albums" where=$sqlFilt sort="sort, name"> | ||
<let name=al_name val="@row | <let name=al_name val="@row.name" /> | ||
<let name=outFunc append> | <let name=outFunc append> | ||
* </let> | * </let> | ||
<let name=outFunc append vars>[{{fullurl:{{PAGENAME}}|artist=[$doArtist$]&album=[$@row | <let name=outFunc append vars>[{{fullurl:{{PAGENAME}}|artist=[$doArtist$]&album=[$@row.id$]}} </let> | ||
<let name=outFunc append copy=al_name /> | <let name=outFunc append copy=al_name /> | ||
<let name=outFunc append>]</let> | <let name=outFunc append>]</let> | ||
Line 37: | Line 43: | ||
<let name=sqlFilt append copy=doArtist /> | <let name=sqlFilt append copy=doArtist /> | ||
</else> | </else> | ||
<for db=audioferret table=" | <let name=outFunc> | ||
{| </let> | |||
<for db=audioferret table="qryTitle_Files" where=$sqlFilt sort="track, name"> | |||
<let name=outFunc append> | <let name=outFunc append> | ||
|- | |||
<let name=outFunc append copy=@row | | '''</let> | ||
<let name=outFunc append copy=@row.track /> | |||
<let name=outFunc append>'''. </let> | <let name=outFunc append>'''. </let> | ||
<let name=outFunc append copy=@row. | <let name=outFunc append copy=@row.name /> | ||
<let name=outFunc append> || [</let> | |||
<let name=outFunc append copy=urlAudio /> | |||
<let name=outFunc append copy=@row.filespec /> | |||
<let name=outFunc append> download]</let> | |||
</for> | </for> | ||
<let name=outFunc append> | |||
|} </let> | |||
</func> | </func> | ||
============================ | ============================ | ||
===== build the output ===== | ===== build the output ===== | ||
============================ | ============================ | ||
Turn off page cache: | Set up the environment: | ||
-- Turn off page cache: | |||
<w3tpl nocache /> | <w3tpl nocache /> | ||
-- base URL for audio files: | |||
<let name=urlAudio>smb://rizzo/shared/sdd/audio/Jukebox/content/</let> | |||
Get the input arguments: | Get the input arguments: | ||
< | <let name=doArtist copy=@query.artist /> | ||
<let name=doArtist val=5 /> | <!-- let name=doArtist val=5 / --> | ||
< | <let name=doAlbum copy=@query.album /> | ||
<let name=doAlbum val= | <!-- let name=doAlbum val=131 / --> | ||
Always show the artists: | Always show the artists: | ||
Line 63: | Line 81: | ||
{| | {| | ||
|- | |- | ||
| '''artists'''</let> | |||
<if flag=doArtist> | <if flag=doArtist> | ||
<let name=doTitles val=1 /> | <let name=doTitles val=1 /> | ||
</if> | </if> | ||
<if flag=doArtist> | <if flag=doArtist> | ||
<let name=out append> || | <let name=out append vars> || '''albums''': [$chosen_artist_name$]</let> | ||
</if> | </if> | ||
<if flag=doTitles> | <if flag=doTitles> | ||
<let name=out append> || | <let name=out append> || '''titles''' (only works from our house network)</let> | ||
</if> | </if> | ||
<let name=out append> | <let name=out append> |
Latest revision as of 01:33, 31 May 2011
The Hypertwin Jukebox Prototype
This was a prototype written in W3TPL; it allowed us to export files over the LAN, but the links were often broken. It is also rather slow, being written in a language being interpreted by a parser written in another interpreted language. I'm leaving it here as an example of working W3TPL code. <hide>
=========
functions
=========
<func GetArtists>
<for db=audioferret table="qryArtists_index" sort="name"> <let name=ar_name val="@row.name" /> <let name=outFunc append>
- </let>
<if comp=@row.id with=$doArtist> <let name=chosen_artist_name copy=ar_name /> <let name=outFunc append></let> <let name=outFunc append copy=ar_name /> <let name=outFunc append></let> </if><else> <let name=outFunc append vars>[$@row.id$ </let> <let name=outFunc append copy=ar_name /> <let name=outFunc append>]</let> </for>
</func>
<func GetAlbums>
<let name=sqlFilt vars>idartist=</let> <let name=sqlFilt append copy=doArtist /> <for db=audioferret table="Albums" where=$sqlFilt sort="sort, name"> <let name=al_name val="@row.name" /> <let name=outFunc append>
- </let>
<let name=outFunc append vars>[$doArtist$&album=[$@row.id$] </let> <let name=outFunc append copy=al_name /> <let name=outFunc append>]</let> </for>
</func>
<func GetTitles>
<if flag=doAlbum> <let name=sqlFilt vars>album_id=</let> <let name=sqlFilt append copy=doAlbum /> </if><else> <let name=sqlFilt vars>artist_id=</let> <let name=sqlFilt append copy=doArtist /> </else> <let name=outFunc><for db=audioferret table="qryTitle_Files" where=$sqlFilt sort="track, name"> <let name=outFunc append>
</let>
<let name=outFunc append copy=@row.track /> <let name=outFunc append>. </let> <let name=outFunc append copy=@row.name /> <let name=outFunc append> || [</let> <let name=outFunc append copy=urlAudio /> <let name=outFunc append copy=@row.filespec /> <let name=outFunc append> download]</let> </for> <let name=outFunc append> |
</let>
</func>
================
build the output
================
Set up the environment: -- Turn off page cache: <w3tpl nocache /> -- base URL for audio files: <let name=urlAudio>smb://rizzo/shared/sdd/audio/Jukebox/content/</let>
Get the input arguments: <let name=doArtist copy=@query.artist /> <let name=doAlbum copy=@query.album />
Always show the artists: <call GetArtists />
<let name=out>
artists</let>
<if flag=doArtist> <let name=doTitles val=1 /> </if> <if flag=doArtist> <let name=out append vars> || albums: [$chosen_artist_name$]</let> </if> <if flag=doTitles> <let name=out append> || titles (only works from our house network)</let> </if> <let name=out append> | ||
</let> <let name=out append copy=outFunc /> <let name=outFunc null /> <if flag=doArtist> <call GetAlbums /> <let name=out append> |
</let>
<let name=out append copy=outFunc /> <let name=outFunc null /> </if> <if flag=doTitles> <call GetTitles /> <let name=out append> |
</let>
<let name=out append copy=outFunc /> <let name=outFunc null /> </if> <let name=out append> |
</let>
===============
show the output
===============
</hide><get name=out />