From 71e4201fed3d8111045b7ce76f19c3af21dd9616 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Mon, 9 Jun 2025 21:27:49 +0800 Subject: [PATCH] add hashtag widget --- app/controllers/universal_tables_controller.rb | 16 ++++++++++++++++ lib/universal_table/engine.rb | 4 ++-- modules/universal_table/_tag_cloud.html.erb | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 modules/universal_table/_tag_cloud.html.erb diff --git a/app/controllers/universal_tables_controller.rb b/app/controllers/universal_tables_controller.rb index 31f73a4..f76f9c3 100644 --- a/app/controllers/universal_tables_controller.rb +++ b/app/controllers/universal_tables_controller.rb @@ -434,4 +434,20 @@ class UniversalTablesController < ApplicationController "mind_map_data" => mindmap.mind_map_data } end + + def tag_cloud + tables = UTable.filter_by_widget_categories(OrbitHelper.widget_categories,false) + tags = TableTag.where(:u_table_id.in => tables.pluck(:id)) + hashtags = tags.map do |tag| + { + "title" => "##{tag.title}", + "count" => tag.table_entries.count, + "url_to_show" => "#{OrbitHelper.widget_more_url}?tag=#{tag.title}" + } + end + { + "hashtags" => hashtags, + "extras" => {} + } + end end diff --git a/lib/universal_table/engine.rb b/lib/universal_table/engine.rb index b070345..7e65ed3 100644 --- a/lib/universal_table/engine.rb +++ b/lib/universal_table/engine.rb @@ -19,7 +19,7 @@ module UniversalTable OrbitApp.registration "UniversalTable", :type => "ModuleApp" do module_label "universal_table.universal_table" base_url File.expand_path File.dirname(__FILE__) - widget_methods ["widget"] + widget_methods ["widget","tag_cloud"] widget_settings [{"data_count"=>30}] # taggable "Bulletin" categorizable @@ -38,7 +38,7 @@ module UniversalTable :priority=>1, :active_for_action=>{'admin/universal_table'=>'index'}, :available_for => 'users' - context_link 'universal_table.new_table', + context_link 'universal_table.new_table', :link_path=>"new_admin_universal_table_path" , :priority=>2, :active_for_action=>{'admin/universal_tables'=>'new'}, diff --git a/modules/universal_table/_tag_cloud.html.erb b/modules/universal_table/_tag_cloud.html.erb new file mode 100644 index 0000000..32f95c0 --- /dev/null +++ b/modules/universal_table/_tag_cloud.html.erb @@ -0,0 +1 @@ +hi \ No newline at end of file