diff --git a/app/controllers/links_controller.rb b/app/controllers/links_controller.rb index 4e1ec9a..3cb26ae 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/links_controller.rb @@ -45,15 +45,17 @@ def destroy def user_links @user = User.find_by(username: params[:username]) return redirect_to root_path, alert: "User not found" if @user.nil? - - @links = @user.links + + @links = @user.links.where(hidden: false, visible: true) + @hidden_links = @user.links.where(hidden: true) @pinned_links = @user.links.where(pinned: true) @achievements = @user.achievements @user.tags = JSON.parse(@user.tags) if @user.tags.is_a?(String) - + # Add debugging Rails.logger.debug "Theme: #{@theme.inspect}" - + Rails.logger.debug "Hidden Links: #{@hidden_links.inspect}" + # Render the appropriate template based on the theme case @theme when 'retro' @@ -84,7 +86,7 @@ def track_click private def link_params - params.require(:link).permit(:url, :title, :description, :position, :icon, :visible, :pinned) + params.require(:link).permit(:url, :title, :description, :position, :icon, :visible, :pinned, :hidden) end def set_theme diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index 364fb35..df76145 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -5,7 +5,6 @@ import "flowbite"; Rails.start(); console.log('Vite ⚡️ Rails'); -console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails'); // Linkarooie console messages console.log('Linkarooie 🌐 Your ultimate link management tool'); @@ -79,3 +78,26 @@ console.log('© 2024 Linkarooie. All rights reserved.'); }); } })(); + +document.addEventListener('DOMContentLoaded', () => { + const pathname = window.location.pathname; + const userPagePattern = /^\/[^/]+$/; // Matches any path with a single segment after the root + + if (userPagePattern.test(pathname)) { + const hiddenLinksData = document.getElementById('hidden-links-data'); + + if (hiddenLinksData) { + const hiddenLinks = JSON.parse(hiddenLinksData.dataset.hiddenLinks); + + if (hiddenLinks.length > 0) { + console.group('Hidden Links'); + hiddenLinks.forEach((link) => { + console.log(`Title: ${link.title}, URL: ${link.url}`); + }); + console.groupEnd(); + } else { + console.log('No hidden links to display.'); + } + } + } + }); \ No newline at end of file diff --git a/app/models/link.rb b/app/models/link.rb index 5191d76..edfd0e0 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -5,4 +5,5 @@ class Link < ApplicationRecord scope :visible, -> { where(visible: true) } scope :pinned, -> { where(pinned: true) } + scope :hidden, -> { where(hidden: true) } end \ No newline at end of file diff --git a/app/views/links/_form.html.erb b/app/views/links/_form.html.erb index b072e97..6944b83 100644 --- a/app/views/links/_form.html.erb +++ b/app/views/links/_form.html.erb @@ -1,8 +1,8 @@ -<%= form_with(model: link, local: true) do |form| %> +<%= form_with(model: link, local: true, class: "max-w-md mx-auto p-4 bg-gray-800 rounded-lg shadow-md") do |form| %> <% if link.errors.any? %> -
+ Find icons at Font Awesome.
+ Use the class name (e.g., fas fa-home
) in the icon field.
+