mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
This commit finalizes the transition from MaterializeCSS to TailwindCSS by: **Layout & Controller Changes:** - Consolidated layouts/tailwind.html.erb into layouts/application.html.erb - Removed `layout 'tailwind'` declarations from 21 controllers - Removed MaterializeCSS CDN link while preserving Material Icons **Asset Cleanup:** - Deleted materialize.min.js (76KB) and materialize-overrides.scss - Removed tailwind.html.erb (no longer needed) - Cleaned up MaterializeCSS-specific JavaScript files **JavaScript Modernization:** - Removed MaterializeCSS initialization and select components - Updated autosave.js and timeline-editor.js to remove M.toast() calls - Deprecated unused React component with MaterializeCSS dependencies **Result:** - Unified TailwindCSS layout system across entire application - Complete removal of MaterializeCSS dependencies - Preserved all functionality through Alpine.js implementations - Clean codebase ready for production 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
101 lines
3.2 KiB
Ruby
101 lines
3.2 KiB
Ruby
class StreamController < ApplicationController
|
|
before_action :authenticate_user!
|
|
before_action :set_stream_navbar_actions, only: [:index, :global]
|
|
before_action :set_stream_navbar_color, only: [:index, :global]
|
|
before_action :set_sidenav_expansion
|
|
before_action :cache_linkable_content_for_each_content_type, only: [:index, :global]
|
|
before_action :load_recent_forum_topics, only: [:index, :global]
|
|
|
|
def index
|
|
@page_title = "What's happening"
|
|
|
|
followed_users = current_user.followed_users.pluck(:id)
|
|
blocked_users = current_user.blocked_users.pluck(:id)
|
|
blocked_by_users = current_user.blocked_by_users.pluck(:id)
|
|
|
|
@feed = ContentPageShare.where(user_id: followed_users + [current_user.id] - blocked_users - blocked_by_users)
|
|
.order('created_at DESC')
|
|
.includes([:content_page, :secondary_content_page])
|
|
.includes({ share_comments: [:user], user: [:avatar_attachment] })
|
|
|
|
# Apply search filter if present
|
|
if params[:search].present?
|
|
search_term = "%#{params[:search]}%"
|
|
@feed = @feed.joins(:user).where(
|
|
"content_page_shares.message ILIKE ? OR users.name ILIKE ? OR users.email ILIKE ?",
|
|
search_term, search_term, search_term
|
|
)
|
|
end
|
|
|
|
@feed = @feed.limit(25)
|
|
end
|
|
|
|
def community
|
|
end
|
|
|
|
def global
|
|
@page_title = "What's happening around the world"
|
|
|
|
blocked_users = current_user.blocked_users.pluck(:id)
|
|
blocked_by_users = current_user.blocked_by_users.pluck(:id)
|
|
|
|
@feed = ContentPageShare.all
|
|
.where.not(user_id: blocked_users + blocked_by_users)
|
|
.order('created_at DESC')
|
|
.includes([:content_page, :secondary_content_page])
|
|
.includes({ share_comments: [:user], user: [:avatar_attachment] })
|
|
|
|
# Apply search filter if present
|
|
if params[:search].present?
|
|
search_term = "%#{params[:search]}%"
|
|
@feed = @feed.joins(:user).where(
|
|
"content_page_shares.message ILIKE ? OR users.name ILIKE ? OR users.email ILIKE ?",
|
|
search_term, search_term, search_term
|
|
)
|
|
end
|
|
|
|
@feed = @feed.limit(25)
|
|
end
|
|
|
|
def set_stream_navbar_color
|
|
@navbar_color = '#CE93D8'
|
|
end
|
|
|
|
# For showing a specific piece of content
|
|
def set_stream_navbar_actions
|
|
@navbar_actions = [
|
|
{
|
|
label: 'You & Your Network',
|
|
href: main_app.stream_path
|
|
},
|
|
{
|
|
label: 'Around the world',
|
|
href: main_app.stream_world_path
|
|
}
|
|
]
|
|
end
|
|
|
|
def set_sidenav_expansion
|
|
@sidenav_expansion = 'community'
|
|
end
|
|
|
|
private
|
|
|
|
def load_recent_forum_topics
|
|
# Get the 5 most recent forum posts and their topics
|
|
recent_posts = Thredded::Post.joins(:topic)
|
|
.where(deleted_at: nil)
|
|
.order(created_at: :desc)
|
|
.limit(10)
|
|
.includes(:topic, :user)
|
|
|
|
# Get unique topics from recent posts, limited to 5
|
|
@recent_forum_topics = recent_posts.map(&:topic)
|
|
.uniq { |topic| topic.id }
|
|
.first(5)
|
|
rescue => e
|
|
Rails.logger.error "Error loading recent forum topics: #{e.message}"
|
|
@recent_forum_topics = []
|
|
end
|
|
end
|