Last active
October 8, 2016 11:15
-
-
Save honewatson/d1341011767707e60fd655ae313fab43 to your computer and use it in GitHub Desktop.
Basic Moon App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lapis = require "lapis" | |
| db = require "lapis.db" | |
| html = require "lapis.html" | |
| queries = require "queries" | |
| config = require("lapis.config").get! | |
| import get_redis from require "lapis.redis" | |
| import notNil from require "utils" | |
| main = require "components.main" | |
| get_set_redis = (widget) => | |
| key = widget.key @req | |
| content = @redis\get key | |
| unless notNil content | |
| @query = widget.query | |
| @view = widget.html | |
| content = @view @query! | |
| @redis\set key, content | |
| return content | |
| class App extends lapis.Application | |
| @before_filter => | |
| @redis = get_redis! | |
| @get_set_redis = get_set_redis | |
| @db = db | |
| [index: "/"]: => | |
| content = @get_set_redis main | |
| { | |
| layout: false, | |
| content | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| queries = require "queries" | |
| html = require "lapis.html" | |
| import render_html from require "lapis.html" | |
| import notNil from require "utils" | |
| key = () => | |
| @req.parsed_url.path | |
| query = () => | |
| @mainResults = db.query(query(queries.main, @blog_id), 0, 40) | |
| html = () => | |
| render_html -> | |
| div class: "body", -> | |
| for post in *@mainResults | |
| div -> | |
| h2 post.post_title | |
| h3 post.post_excerpt | |
| post.post_read_more | |
| export { :key, :query, :html } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment