prototype mobile interface

This commit is contained in:
albert
2011-11-06 16:59:21 -05:00
parent 5158d1b274
commit 19e5e521f5
13 changed files with 288 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
class PostPresenter < Presenter
def self.preview(post)
def self.preview(post, options = {})
if post.is_deleted? && !CurrentUser.is_privileged?
return ""
end
@@ -9,8 +9,10 @@ class PostPresenter < Presenter
flags << "flagged" if post.is_flagged?
flags << "deleted" if post.is_deleted?
path = options[:path_prefix] || "/posts"
html = %{<article class="post-preview" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{flags.join(' ')}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}">}
html << %{<a href="/posts/#{post.id}">}
html << %{<a href="#{path}/#{post.id}">}
if post.is_image?
html << %{<img src="#{post.preview_file_url}">}
@@ -51,8 +53,8 @@ class PostPresenter < Presenter
end
end
def tag_list_html(template)
def tag_list_html(template, options = {})
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
@tag_set_presenter.tag_list_html(template, :show_extra_links => CurrentUser.user.is_privileged?)
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
end
end

View File

@@ -36,20 +36,26 @@ private
html << %{<li class="category-#{categories[tag]}">}
current_query = template.params[:tags] || ""
if categories[tag] == 1
html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> }
else
html << %{<a class="wiki-link" href="/wiki_pages?title=#{u(tag)}">?</a> }
end
unless options[:name_only]
if categories[tag] == 1
html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> }
else
html << %{<a class="wiki-link" href="/wiki_pages?title=#{u(tag)}">?</a> }
end
if CurrentUser.user.is_privileged?
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">&ndash;</a> }
if CurrentUser.user.is_privileged?
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">&ndash;</a> }
end
end
humanized_tag = tag.tr("_", " ")
html << %{<a href="/posts?tags=#{u(tag)}">#{h(humanized_tag)}</a> }
html << %{<span class="post-count">} + counts[tag].to_s + %{</span>}
path = options[:path_prefix] || "/posts"
html << %{<a href="#{path}?tags=#{u(tag)}">#{h(humanized_tag)}</a> }
unless options[:name_only]
html << %{<span class="post-count">} + counts[tag].to_s + %{</span>}
end
html << "</li>"
html