DekiScript Primer

33 %
67 %
Information about DekiScript Primer

Published on July 17, 2008

Author: mindtouch

Source: slideshare.net

Description

Introduction to DekiScript, the scripting language in MindTouch Deki

DekiScript Primer

Motivation for DekiScript Use Case Embed dynamic content Create dynamic layouts Anybody can use it safely (i.e. not JavaScript) Design principles Not case-sensitive Simple data types Native support for XML Concurrent (e.g. write-once, read-many)

Use Case

Embed dynamic content

Create dynamic layouts

Anybody can use it safely (i.e. not JavaScript)

Design principles

Not case-sensitive

Simple data types

Native support for XML

Concurrent (e.g. write-once, read-many)

Data Types Type Value Nil nil, null, _ Bool true, false Number (num) 123, -1.23e4 String (str) “ hi”, ‘bye’ List [ 1, 2, 3 ] Map { a: 1, b: 2, c: 3 } Uri n/a Xml n/a

Basic Operations DekiScript Output {{ nil }} {{ “1” + “23” }} 24 {{ 1 .. 23 }} 123 {{ [ 1 ] .. [ 2, 3 ] }} [ 1, 2, 3] {{ { x: 1 } .. { y : 2 } }} { x: 1, y: 2 } {{ “123” != nil ? “1” : 0 }} 1 {{ nil ?? 123 }} 123 {{ false ?? 123 }} False {{ #[ 1, 2, 3 ] }} 3

Control Flow Statements {{ var x = 0; foreach(var y in [ 1, 2, 3, 4 ]) { if(y % 2 == 0) { let x += y; } } x; }} DekiScript var x = 123; let x += 1; if(x) { … } else { … } foreach(var x in y) { … }

User object Properties user.name User name user.homepage Homepage object user.anonymous True if user is not logged in user.gravatar Gravatar image user.uri Uri for user homepage user.api Uri for user web-service

Page object Properties page.name Page name page.title Page title page.uri Uri for page page.api Uri for page web-service page.date Date when page was edited page.author Last author on page page.subpages Sub-pages of current page page.files Files attached to page page.tags Tags associated with page

Site object Properties site.name Name of site site.hostname Internet hostname site.api Uri for site web-service site.uri Uri for site homepage site.homepage Homepage object site.feed Uri for site RSS feed site.pagecount Number of pages on site site.usercount Number of registered users

Sample: Gravatars Gravatar for most recent page author <div style=“float: right;”> <center> {{ page.author.gravatar }}<br/> {{ web.link(user.uri, user.name) }} </center> </div>

Gravatar for most recent page author

Control Flow Attributes DekiScript Attributes <div block=“var f = page.files”>…</div> <ul if=“#f”>…</ul> <li foreach=“var x in page.files” where=“string.endswith(x.name, ‘.doc’)”> … </li> <span init=“var f = page.files” if=“#f”>…</span>

Sample: Gravatars, The Sequel Gravatars for sub-page authors <table init=“var s = page.subpages” if=“#s” class=“table”> <tr> <th>Title</th> <th>Author</th> <th>Gravatar</th> </tr> <tr foreach=“var p in s” class=“{{__count % 2 ? ‘bg2’ : ‘bg1’}}” > <td>{{ web.link(p.uri, p.title) }}</td> <td>{{ web.link(p.author.uri, p.author.name) }}</td> <td>{{ p.author.gravatar }}</td> </tr> </table>

Gravatars for sub-page authors

Finding Functions

Advanced Constructs Construct {{save: … }} Substitute on save {{edit: …}} Substitute on edit <p class=“noinclude”> Hide when included <p class=“includeonly”> Show only when included <pre|span class=“script”> Contents is script <pre class=“script” function=“syntax.xml($, true)”> Content transforms $ Template parameters __request.args Query request parameters

Sample: Custom Search Form Embed a form for constrained search Use this page to only search pages tagged with &quot;extensions&quot;: {{ dhtml.inputbox{value: __request.args.q, button: &quot;Search&quot;, field: &quot;q&quot;, publish: page.uri} }} {{ if(__request.args.q) { wiki.search(__request.args.q, _, _, &quot;tag:extensions&quot;) } }}

Embed a form for constrained search

Sample: Notebook Simple notebook application <p>{{ wiki.create{ label: &quot;Add a note&quot;, template: &quot;NotebookPage&quot;, title: date.format(date.now, &quot;yyyy MMMM, d&quot;) .. ' (' .. user.name .. ')' } }}</p> <ul> <li foreach=&quot;var p in page.subpages&quot;> {{web.link(p.uri, p.title)}} <span style=&quot;color: rgb(128, 128, 128); font-size: small;”> ({{#p.comments}} comments) </span><br /> {{ var h = wiki.page(p.path); h[&quot;//*[@class='summary']&quot;] }} </li> </ul>

Simple notebook application

Questions? Slides and samples available at http://wiki.developer.mindtouch.com/DekiCon Discussion forums at http://forums.developer.mindtouch.com Latest news at http://www.mindtouch.com/blog

Slides and samples available at

http://wiki.developer.mindtouch.com/DekiCon

Discussion forums at

http://forums.developer.mindtouch.com

Latest news at

http://www.mindtouch.com/blog

Add a comment

Related presentations

Related pages

Space Elevator: August 2008 | SpaceRef

Space Elevator: August 2008 ... it provides a great set of mashup tools and DekiScript scripting language allowing me ... A Primer on Public Policy, Why ...
Read more

DekiScript Primer – 資訊與工作

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)
Read more

What Ultra Collaborative Intranet Platform is best for ...

8 Responses to “What Ultra Collaborative Intranet Platform is best for Total Attorneys? ... DekiScript, allows even novice ... needed primer paint says:
Read more

ToDoList – Dekiscript – 資訊與工作

ToDoList – Dekiscript. 張貼者 tcr 於 19 四月 2011, 5:26 ... « DekiScript Primer. Post Comment to Homepage ...
Read more

MindTouch Announces MindTouch 2009, a Significant Leap ...

MindTouch Announces MindTouch 2009, a Significant Leap Forward in ... to the MindTouch integrated scripting language DekiScript. ... Tech Primer: When ...
Read more

Primer Selection - Documents

Primer Selection For any process, the primer selected for use in PCR to amplify some piece of DNA is the first point that determines what sort of ...
Read more

Primer - Documents

Primer. Perdóname mi “portuñol”. Gerson Rolim Director Ejecutivo. Cámara Brasileña de Comercio Electrónico. Agenda | Programación. La camara-e ...
Read more