lib/pullentity-client/helpers.rb in pullentity-client-0.0.7 vs lib/pullentity-client/helpers.rb in pullentity-client-0.0.8

- old
+ new

@@ -1,146 +1,52 @@ require "middleman" +require 'middleman-target' module Pullentity::Client::Helpers - #TODO separate elements in specific classes: - # views, asides, articles, header, tabbar, toolbar etc... - - def footer(opts={}, &block) - content_tag :footer , opts do - capture(&block) - end - end - - def article(opts={}, &block) - content_tag :article , opts do - capture(&block) - end - end - - def section(opts={}, &block) - content_tag :section , opts do - capture(&block) - end - end - - def header(opts={}, &block) - content_tag :header , opts do - capture(&block) - end - end - - def hgroup(opts={}, &block) - if block_given? - content_tag :hgroup, options do - capture(&block) - end + def javascript_include_tag(file) + if target?(:pullentity) + path = "/uploads/theme_asset/#{site_name}/theme/#{theme_name}/assets/#{file}" + "<script src='#{path}.js' type='text/javascript'></script>" else - content_tag :hgroup do - content_tag( :h1 , opts[:title]).concat( - content_tag( :h2 , opts[:subtitle]) - ) - end + super end end - def list_view(opts={}, &block) - options = {:class=>opts[:class]}.merge({"data-type" => "listview"}) - content_tag :ul, options do - capture(&block) - end - end - - def list_item(opts={}, &block) - options = {:class=>opts[:class]} - options = options.merge({ :class=> "#{options[:class]} list-divider"}) if opts[:divider] == true - arrow = content_tag :div , :class=>"aside" do - content_tag( :i, "",{:class=>"icon-chevron-#{opts[:arrow]}"}) - end if opts[:arrow].present? - - if block_given? - content_tag :li, options do - capture(&block) << (arrow || "") - end + def stylesheet_link_tag(file) + if target?(:pullentity) + path = "/uploads/theme_asset/#{site_name}/theme/#{theme_name}/assets/#{file}" + "<link href='#{path}.css' media='screen' rel='stylesheet' type='text/css' />" else - content_tag :li, options do - content_tag :h1 do - opts[:content] - end - end + super end end - def divider(opts={}, &block) - if block_given? - list_item({:divider=>true}.merge(opts)) do - capture(&block) - end - else - list_item({:divider=>true}.merge(opts)) + def test_data_include_tag + unless target?(:pullentity) + javascript_include_tag "test-data" end + end + def site_name + hsh = YAML.load_file(location + "pullentity.yml") + hsh["site"] end - def nav(opts={}, &block) - if block_given? - content_tag(:nav, opts) do - capture(&block) - end - else - end + def theme_name + hsh = YAML.load_file(location + "pullentity.yml") + hsh["theme_name"] end - def tabbar(opts={}, &block) - opts = opts.merge({"data-type" => "tabbar"}) - nav(opts, &block) + def location + @location ||= Pathname.new(Dir.pwd) end - def toolbar(opts={}, &block) - opts = opts.merge({"data-type" => "toolbar"}) - if opts[:control] - auto = opts[:auto] ? "autoWidth" : "" - nav(opts.reject!{ |k| k == :control || k == :auto }) do - content_tag(:div, :class=>"control-group #{auto}") do - capture(&block) - end - end + def asset_pathxxxx(file) + if target?(:pullentity) + 'yea' else - nav(opts, &block) + super end - end - - def icon(type, opts={}, &block) - if block_given? - capture(&block) << - content_tag( :i, "",{:class=>"icon-#{type}"}) - else - name = opts[:text].present? ? content_tag( :span, opts[:text]) : "" - name << - content_tag( :i, "",{:class=>"icon-#{type}"}) - end - end - - def dialog(opts, &block) - options = {:role => "dialog", :data=>{:type=>opts[:type] || "modal", :transition=>opts[:transition] || "slideup"}} - opts = opts.merge(options) - if block_given? - content_tag(:div, opts) do - capture(&block) - end - else - end - end - - def render_tabbar(tabbar) - partial("views/tabbars/#{tabbar}") - end - - def render_dialog(dialog) - partial("views/dialogs/#{dialog}") - end - - def render_toolbar(tabbar) - partial("views/toolbars/#{tabbar}") end end \ No newline at end of file