Permalink
Browse files

Added tag cloud page

  • Loading branch information...
1 parent 527b385 commit 83b11d3d0f28793a63f794f33d522d328f5f7b88 @makaroni4 makaroni4 committed Feb 19, 2013
@@ -0,0 +1,40 @@
+section.jqcloud {
+ overflow: hidden;
+ position: relative;
+ font-size: 10px;
+ line-height: normal;
+
+ a {
+ color: inherit;
+ }
+
+ a:hover {
+ color: #c1c1c1;
+ }
+
+ span {
+ padding: 0;
+ }
+
+ span.w10 { font-size: 550%; }
+ span.w9 { font-size: 500%; }
+ span.w8 { font-size: 450%; }
+ span.w7 { font-size: 400%; }
+ span.w6 { font-size: 350%; }
+ span.w5 { font-size: 300%; }
+ span.w4 { font-size: 250%; }
+ span.w3 { font-size: 200%; }
+ span.w2 { font-size: 150%; }
+ span.w1 { font-size: 100%; }
+
+ span.w10 { color: #9628A1; }
+ span.w9 { color: #5429A3; }
+ span.w8 { color: #7A3BEC; }
+ span.w7 { color: #986AEC; }
+ span.w6 { color: #A66500; }
+ span.w5 { color: #BF8830; }
+ span.w4 { color: #FF9C00; }
+ span.w3 { color: #A69100; }
+ span.w2 { color: #BFAE30; }
+ span.w1 { color: #FFB540; }
@killthekitten

killthekitten Feb 20, 2013

Contributor

No need to specify span in span.class

@releu

releu Feb 20, 2013

Owner

It's inside the jqcloud section. I worry about span.wX duplications..

+}
@@ -1,4 +1,6 @@
class TagsController < ApplicationController
+ layout :choose_layout
+
def show
if @tag = Tag.find_by_name(params[:id])
redirect_to @tag.entity if @tag.alias?
@@ -10,4 +12,18 @@ def show
render 'search/nothing'
end
end
+
+ def cloud
+ @tags = Tag.for_cloud
+ end
+
+ private
+ def choose_layout
+ case action_name
+ when 'cloud'
+ 'sidebarless'
+ else
+ 'application'
+ end
+ end
end
View
@@ -13,8 +13,9 @@ def initialize(user)
can :not_found, :errors
can :index, [:'users/followings', :'users/followers']
can :show, :landings
- can [:history, :show], :'tags/wikis'
+ can [:history, :show], :'tags/wikis'
can :show, :maps
+ can :cloud, :tags
if user
can(:access, :all) and return if user.admin?
View
@@ -23,7 +23,7 @@ class Tag < ActiveRecord::Base
validates :name, presence: true, format: { with: /[a-z]+/ }
scope :real, where(entity_id: nil)
-
+ scope :for_cloud, select("name AS text, taggings_count AS weight, TEXTCAT('/tags/', tags.name) AS link").order('taggings_count DESC').limit(75)
scope :popular, (lambda do |limit = 100|
real.order('taggings_count desc').limit(limit)
end)
@@ -0,0 +1,38 @@
+- content_for(:head) do
+ - if user_signed_in?
+ javascript:
+ window.current_user = {
+ username: "#{current_user.username}",
+ likes: #{current_user.likes.pluck(:post_id).to_json},
+ observings: #{current_user.observings.pluck(:post_id).to_json},
+ bookmarks: #{current_user.bookmarks.pluck(:post_id).to_json},
+ following: #{current_user.followings.pluck(:followed_user_id).to_json},
+ subscriptions: #{current_user.subscriptions.pluck(:tag_id).to_json},
+ admin: #{current_user.admin?},
+ oauth: "#{current_user.oauth_token}"
+ }
+
+- content_for(:header) do
+ header class="main"
+ div class="group hr"
+ h1 = link_to_unless_current 'Gistflow', root_path
+ div class="map" = link_to(map_path, title: 'Gistflow in the World') { '<i class="icon-globe"></i>'.html_safe }
+ = render 'search/form'
+ nav class="user"
+ = ul authentication_items, class: 'user-menu'
+ - if user_signed_in?
+ = ul [link_to('<i class="icon-edit"></i>'.html_safe, new_post_path)], class: 'post-menu'
+ = render_flash
+
+- content_for(:footer) do
+ footer class="main"
+ ul class="links"
+ li = link_to 'Posts leaderboard', leaderboard_posts_path
+ li = link_to 'Tags cloud', cloud_tags_path
+ li = link_to 'Create issue', 'https://github.com/gistflow/gistflow/issues'
+ li = mail_to 'info@gistflow.com', 'Email us', :encode => :hex
+ = link_to '<g>', root_path, class: :logo
+ p class="credentials"
+ | &copy; 2013 #{link_to 'Gistflow', root_path} with #{link_to 'Evrone', 'http://evrone.ru'}
+
+= render 'layouts/base'
@@ -0,0 +1,8 @@
+section class="sidebar"
+ = render partial: 'general/about'
+ = render :partial => 'users/todolist' if user_signed_in?
+ = yield(:sidebar)
+ = render partial: 'shared/facebook'
+ = render partial: 'account/gists/sidebar' if user_signed_in? && gists_page?
+ = render 'account/bookmarks/sidebar' if user_signed_in?
+ = render 'account/tags/sidebar'
@@ -3,49 +3,6 @@
- if content_for?(:submenu)
nav class="submenu" = yield(:submenu)
= yield
- section class="sidebar"
- = render partial: 'general/about'
- = render :partial => 'users/todolist' if user_signed_in?
- = yield(:sidebar)
- = render partial: 'shared/facebook'
- = render partial: 'account/gists/sidebar' if user_signed_in? && gists_page?
- = render 'account/bookmarks/sidebar' if user_signed_in?
- = render 'account/tags/sidebar'
+ = render 'layouts/sidebar'
-- content_for(:head) do
- - if user_signed_in?
- javascript:
- window.current_user = {
- username: "#{current_user.username}",
- likes: #{current_user.likes.pluck(:post_id).to_json},
- observings: #{current_user.observings.pluck(:post_id).to_json},
- bookmarks: #{current_user.bookmarks.pluck(:post_id).to_json},
- following: #{current_user.followings.pluck(:followed_user_id).to_json},
- subscriptions: #{current_user.subscriptions.pluck(:tag_id).to_json},
- admin: #{current_user.admin?},
- oauth: "#{current_user.oauth_token}"
- }
-
-- content_for(:header) do
- header class="main"
- div class="group hr"
- h1 = link_to_unless_current 'Gistflow', root_path
- div class="map" = link_to(map_path, title: 'Gistflow in the World') { '<i class="icon-globe"></i>'.html_safe }
- = render 'search/form'
- nav class="user"
- = ul authentication_items, class: 'user-menu'
- - if user_signed_in?
- = ul [link_to('<i class="icon-edit"></i>'.html_safe, new_post_path)], class: 'post-menu'
- = render_flash
-
-- content_for(:footer) do
- footer class="main"
- ul class="links"
- li = link_to 'Posts leaderboard', leaderboard_posts_path
- li = link_to 'Create issue', 'https://github.com/gistflow/gistflow/issues'
- li = mail_to 'info@gistflow.com', 'Email us', :encode => :hex
- = link_to '<g>', root_path, class: :logo
- p class="credentials"
- | &copy; 2013 #{link_to 'Gistflow', root_path} with #{link_to 'Evrone', 'http://evrone.ru'}
-
-= render 'layouts/base'
+= render 'layouts/contents'
@@ -0,0 +1,5 @@
+- content_for(:main) do
+ section class="main"
+ = yield
+
+= render 'layouts/contents'
@@ -0,0 +1,15 @@
+= javascript_include_tag 'jqcloud'
+
+- cache 'tag_cloud' do
+ javascript:
+ var word_array = #{@tags.to_json.html_safe};
+
+ $(function() {
+ $(".cloud").jQCloud(word_array, {
+ width: 960,
+ height: 400,
+ delayedMode: true
+ });
+ });
+
+ section class='cloud'
View
@@ -31,7 +31,7 @@ class Application < Rails::Application
# Activate observers that should always be running.
# config.active_record.observers = :post_sweeper
-
+ config.assets.precompile << ['jqcloud.js']
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
View
@@ -51,6 +51,7 @@
get '/search/:query' => 'searches#show', as: 'show_search'
resources :tags, only: :show do
+ get :cloud, on: :collection
resource :wiki, module: :tags, only: [:show, :edit, :update] do
get 'history'
end

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 83b11d3

Please sign in to comment.