Created
November 8, 2016 22:25
-
-
Save makevoid/c908ca67d3cd25247597e360eae94c53 to your computer and use it in GitHub Desktop.
Jasonette runkit endpoint - render a json object, stringify it, add a bit of jasonette, bam! you have a native 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
| // endpoint: https://runkit.io/makevoid/jasonette-3/branches/master | |
| // ---------------------------------------------------------------- | |
| // var cheerio = require('cheerio'), | |
| // $ = cheerio.load('<h2 class = "title">Hello world</h2>'); | |
| // todo: idea for next app, scrape some html, extract links, display them in native app | |
| // $('h2.title').text('Hello there!'); | |
| // $('h2').addClass('welcome'); | |
| // { | |
| // type: "button", | |
| // text: "Moar Doge!", | |
| // style: { | |
| // width: "50", | |
| // height: "50", | |
| // background: "#f4bb00", | |
| // size: "24" | |
| // }, | |
| // action: { | |
| // type: "$reload" | |
| // } | |
| // }, | |
| const app = { | |
| "$jason": { | |
| head: { | |
| title: "SampleApp" | |
| }, | |
| body: { | |
| header: { title: "SampleApp", style: { shy: true } }, | |
| sections: [{ | |
| items: [ | |
| {type: "label", text: "Welcome to the SampleApp app! Enjoy some Doge from Giphy."}, | |
| {type:"image",url:"http://media4.giphy.com/media/ZO8upuwNKfpm0/giphy.gif"}, {type:"image",url:"http://media4.giphy.com/media/wZWKSfPaFhNSw/giphy.gif"}, {type:"image",url:"http://media0.giphy.com/media/14ldcdd6sPu252/giphy.gif"}, {type:"image",url:"http://media0.giphy.com/media/oqbkWDL2MvRcY/giphy.gif"}, {type:"image",url:"http://media2.giphy.com/media/10ECejNtM1GyRy/giphy.gif"}, {type:"image",url:"http://media0.giphy.com/media/ToMjGpjwk1MxyYRcQnK/giphy.gif"}, | |
| {type: "label", text: "Built with Jasonette and Runkit - @makevoid"} | |
| ] | |
| }] | |
| } | |
| } | |
| } | |
| exports.endpoint = function(request, response) { | |
| response.end( JSON.stringify(app) ) // render the app object/constant a JSON string (note: make sure you're not rendering objects with references, use only basic objects types + arrays, strings, etc... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment