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">&quot;</span><span class="synConstant">access_token=</span><span class="synSpecial">#{</span>access_token<span class="synSpecial">}&quot;</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">&quot;</span><span class="synConstant">?</span><span class="synSpecial">#{</span>param<span class="synSpecial">}&quot;</span>)
      json = <span class="synType">JSON</span>.parse(response.body)
    }

    <span class="synIdentifier">@urls</span> = []
    json[<span class="synSpecial">&quot;</span><span class="synConstant">data</span><span class="synSpecial">&quot;</span>].each <span class="synStatement">do</span> |<span class="synIdentifier">item</span>|
      <span class="synIdentifier">@urls</span> &lt;&lt; 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">:&quot;plugin/lokka-hello/views/index&quot;</span>, <span class="synConstant">:layout</span> =&gt;<span class="synConstant">:&quot;admin/layout&quot;</span>
  <span class="synStatement">end</span>
<span class="synPreProc">end</span>

end end

Related contents