Blog engine example

This example demonstrates various language features such as:

  • defining models, validation and relations
  • permissions
  • queries
  • separators
  • working with the model, page, css and html nodes and connecting them through node inheritance

Blog engine example

This example demonstrates various language features such as:

  • defining models, validation and relations
  • permissions
  • queries
  • separators
  • working with the model, page, css and html nodes and connecting them through node inheritance

 

// comment model
model#comment {
    
    // content
    bodystring 1..
 
    // relations
    byuser != null
 
    // permissions
    deleteupdate { by == @user }
 
}
 
// post model
model#post {
    
    // content
    titlestring 1..140
    bodystring 1..
 
    // relations and permissions
    authoruser != null
    tagsstring#tag[]
    comments: model#comment[] {
        // author permissions on the comments
        deleteupdate { author == @user }
    }
    
    // author permissions on the post
    deleteupdate { author == @user }
 
}
 
// site css
css#site {
    
}
 
// site html with site css
html#site : css#site, html {
    
}
 
// index page
page#index {
    posts.latest {
        post foreach model#post orderby post.date take 10
    }
    posts.featured {
        post from model#post where post.featured orderby post.date take 1
    }
}
 
 
// index view
view#index : page#index, html#site {
    body {
        div.posts : posts.latest {
            div.post : post {
                h1.title { post.title }
                div.body { post.body }
                div.meta {
                     foreach tag in post.tags {
                        a { "{tag}" -> view#bytag }
span : ", " between
                    }
                }
            }
        }
    }   
    
}

Last edited Oct 30, 2010 at 8:43 PM by jimmeyer, version 6

Comments

No comments yet.