diff --git a/app/controllers/links_controller.rb b/app/controllers/links_controller.rb index 071cac1..4e1ec9a 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/links_controller.rb @@ -1,5 +1,6 @@ class LinksController < ApplicationController before_action :authenticate_user!, except: [:index, :show, :user_links, :track_click] + before_action :set_theme, only: [:user_links] # Add this line def index @links = Link.order(:position) @@ -43,10 +44,27 @@ def destroy def user_links @user = User.find_by(username: params[:username]) - @links = @user.links.where(visible: true).order(:position) - @pinned_links = @user.links.where(visible: true, pinned: true).order(:position) - @achievements = @user.achievements.order(date: :desc) + return redirect_to root_path, alert: "User not found" if @user.nil? + + @links = @user.links + @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}" + + # Render the appropriate template based on the theme + case @theme + when 'retro' + render 'user_links_retro' + when 'win95' + render 'user_links_win95' + when 'win98' + render 'user_links_win98' + else + render 'user_links' + end end def track_click @@ -68,4 +86,9 @@ def track_click def link_params params.require(:link).permit(:url, :title, :description, :position, :icon, :visible, :pinned) end + + def set_theme + # Determine the theme either from a query parameter or route segment + @theme = params[:theme] || 'default' + end end \ No newline at end of file diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index 0111015..364fb35 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -1,34 +1,81 @@ -// To see this message, add the following to the `` section in your -// views/layouts/application.html.erb -// -// <%= vite_client_tag %> -// <%= vite_javascript_tag 'application' %> import Rails from "@rails/ujs"; -import "chartkick/chart.js" +import "chartkick/chart.js"; import "flowbite"; Rails.start(); -console.log('Vite ⚡️ Rails') - -// If using a TypeScript entrypoint file: -// <%= vite_typescript_tag 'application' %> -// -// If you want to use .jsx or .tsx, add the extension: -// <%= vite_javascript_tag 'application.jsx' %> - -console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify.app/guide/rails') - -// Example: Load Rails libraries in Vite. -// -// import * as Turbo from '@hotwired/turbo' -// Turbo.start() -// -// import ActiveStorage from '@rails/activestorage' -// ActiveStorage.start() -// -// // Import all channels. -// const channels = import.meta.globEager('./**/*_channel.js') - -// Example: Import a stylesheet in app/frontend/index.css -// import '~/index.css' +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'); +console.log('Simplify your online presence with a single link.'); +console.log('© 2024 Linkarooie. All rights reserved.'); + +// Easter egg for "iddqd" +(function () { + let inputBuffer = ''; + + // Listen for keypress events in the browser + window.addEventListener('keydown', function (event) { + inputBuffer += event.key; + + // Check if 'iddqd' was typed + if (inputBuffer.toLowerCase().includes('iddqd')) { + activateGodMode(); + inputBuffer = ''; // Reset buffer after activation + } + + // Clear the buffer if it gets too long + if (inputBuffer.length > 10) inputBuffer = inputBuffer.slice(-10); + }); + + function activateGodMode() { + console.log('%c God Mode Activated! You are now invincible! ', 'background: #222; color: #bada55; font-size: 16px;'); + + // ASCII art + const asciiArt = ` ++-----------------------------------------------------------------------------+ +| | |\\ -~ / \\ / | +|~~__ | \\ | \\/ /\\ /| +| -- | \\ | / \\ / \\ / | +| |~_| \\ \\___|/ \\/ / | +|--__ | -- |\\________________________________/~~\\~~| / \\ / \\ | +| |~~--__ |~_|____|____|____|____|____|____|/ / \\/|\\ / \\/ \\/| +| | |~--_|__|____|____|____|____|____|_/ /| |/ \\ / \\ / | +|___|______|__|_||____|____|____|____|____|__[]/_|----| \\/ \\ / | +| \\mmmm : | _|___|____|____|____|____|____|___| /\\| / \\ / \\ | +| B :_--~~ |_|____|____|____|____|____|____| | |\\/ \\ / \\ | +| __--P : | / / / | \\ / \\ /\\| +|~~ | : | / ~~~ | \\ / \\ / | +| | |/ .-. | /\\ \\ / | +| | / | | |/ \\ /\\ | +| | / | | -_ \\ / \\ | ++-----------------------------------------------------------------------------+ +| | /| | | 2 3 4 | /~~~~~\\ | /| |_| .... ......... | +| | ~|~ | % | | | ~J~ | | ~|~ % |_| .... ......... | +| AMMO | HEALTH | 5 6 7 | \\===/ | ARMOR |#| .... ......... | ++-----------------------------------------------------------------------------+ + `; + + console.log(asciiArt); + + // Create a div to display Doom information + const infoDiv = document.createElement('div'); + infoDiv.innerHTML = ` +
+

You've unlocked a secret!

+

Doom is a 1993 first-person shooter game developed by id Software. It was created by John Carmack and John Romero, among others. The game is considered one of the most significant titles in video game history, pioneering immersive 3D graphics, networked multiplayer gaming, and support for custom mods and expansions.

+

The "iddqd" command is a famous cheat code that grants invulnerability, often referred to as "God Mode".

+

Fun Fact: The name "Doom" was inspired by a line from the movie "The Color of Money" starring Tom Cruise.

+ +
+ `; + document.body.appendChild(infoDiv); + + // Add event listener to the close button to remove the div + document.getElementById('closeInfo').addEventListener('click', function() { + document.body.removeChild(infoDiv); + }); + } +})(); diff --git a/config/routes.rb b/config/routes.rb index e04ae32..bd7d7bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,26 +1,33 @@ Rails.application.routes.draw do get 'analytics/index' - - # Use the custom registrations controller in all environments + + # Devise routes for user registration devise_for :users, controllers: { registrations: 'users/registrations' } + # Routes for links with standard RESTful actions resources :links do member do get :track_click end end + # Sidekiq monitoring require 'sidekiq/web' require 'sidekiq-scheduler/web' mount Sidekiq::Web => '/sidekiq' - # Other routes + # Custom routes for user-specific views and analytics get '/:username/analytics', to: 'analytics#index', as: :user_analytics - get "up" => "rails/health#show", as: :rails_health_check + get '/:username(/:theme)', to: 'links#user_links', as: :user_links, constraints: { theme: /retro|win95|win98/ } + + # Health check route + get 'up' => 'rails/health#show', as: :rails_health_check + + # Root route root to: 'pages#home' - resources :links, only: [:index, :show, :new, :create, :edit, :update, :destroy] + + # Additional resources resources :achievements, only: [:index, :show, :new, :create, :edit, :update, :destroy] - get '/:username', to: 'links#user_links', as: 'user_links' end \ No newline at end of file