LokkaでHamlテンプレートの利用
更新日:2018.08.04
作成日:2011.12.18
hamlで、admin/layoutのテンプレートを利用するまでできた。
Lokkaのthemeのレイアウトテンプレートを使うにはどうすればいいんだろう?
module Lokka module Hello def self.registered(app) app.get '/hello' do require 'uri' require 'net/https' require 'json' require 'haml'url = <span class="synSpecial">'</span><span class="synConstant">https://api.instagram.com/v1/users/1250725/media/recent</span><span class="synSpecial">'</span> access_token = <span class="synType">YOUR_ACESS_TOKEN</span> param = <span class="synSpecial">"</span><span class="synConstant">access_token=</span><span class="synSpecial">#{</span>access_token<span class="synSpecial">}"</span> json = <span class="synConstant">nil</span> uri = <span class="synType">URI</span>.parse(url) https = <span class="synType">Net</span>::<span class="synType">HTTP</span>.new(uri.host,<span class="synConstant">443</span>) https.use_ssl = <span class="synConstant">true</span> https.start { response = https.get(uri.path + <span class="synSpecial">"</span><span class="synConstant">?</span><span class="synSpecial">#{</span>param<span class="synSpecial">}"</span>) json = <span class="synType">JSON</span>.parse(response.body) } <span class="synIdentifier">@urls</span> = [] json[<span class="synSpecial">"</span><span class="synConstant">data</span><span class="synSpecial">"</span>].each <span class="synStatement">do</span> |<span class="synIdentifier">item</span>| <span class="synIdentifier">@urls</span> << item[<span class="synSpecial">'</span><span class="synConstant">images</span><span class="synSpecial">'</span>][<span class="synSpecial">'</span><span class="synConstant">thumbnail</span><span class="synSpecial">'</span>][<span class="synSpecial">'</span><span class="synConstant">url</span><span class="synSpecial">'</span>] <span class="synStatement">end</span> haml<span class="synConstant">:"plugin/lokka-hello/views/index"</span>, <span class="synConstant">:layout</span> =><span class="synConstant">:"admin/layout"</span> <span class="synStatement">end</span> <span class="synPreProc">end</span>
end end
Related contents
TECH
2011.12.15
undefined method `bytesize' for エラー。 -Instagramのプラグインが作りたい-
TECH
2011.12.13
Lokkaインストール。bundle installではまった。
TECH
2012.01.29
お名前.comで取得したドメインでHeroku×Lokkaを動かすまで