diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 267ab0e7..a076e4bd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -60,17 +60,11 @@ def wakatime_setup end def wakatime_setup_step_2 - end - - def wakatime_setup_step_3 - end - - def wakatime_setup_step_4 @no_instruction_wording = [ - "There is no step 4, lol.", - "There is no step 4, psych!", - "Tricked ya! There is no step 4.", - "There is no step 4, gotcha!" + "There is no step 2, lol.", + "There is no step 2, psych!", + "Tricked ya! There is no step 2.", + "There is no step 2, gotcha!" ].sample end diff --git a/app/views/users/wakatime_setup.html.erb b/app/views/users/wakatime_setup.html.erb index ce29ea5c..34cd2a55 100644 --- a/app/views/users/wakatime_setup.html.erb +++ b/app/views/users/wakatime_setup.html.erb @@ -2,99 +2,34 @@

Hackatime Setup

-
-
1
-
-
2
-
-
3
-
-
4
-
+
+ -
-
-

🍎 Mac/Linux/Codespaces users:

-
-

On GitHub Codespaces?

-

No worries! Here's how to find your terminal:

-
    -
  1. Look at the bottom of your Codespaces window for a panel
  2. -
  3. Click the "Terminal" tab (it's usually already open!)
  4. -
  5. If you don't see it, press Ctrl+` (or Cmd+` on Mac)
  6. -
  7. You should see a command prompt with your username - that's your terminal! Keep going with the instructions below to continue setting up Hackatime.
  8. -
-
+

+ Your API key is + <%= @current_user_api_key %> + +

+
-
-
    -
  1. - Find your terminal: -
      -
    • Mac: Open the "Terminal" app (search for it in Spotlight)
    • -
    • Linux: Open your terminal emulator
    • -
    • Codespaces: See the blue box above ☝️
    • -
    -
  2. -
  3. Copy the magic command below (click the Copy button - much easier!)
  4. -
  5. Paste it in your terminal and press Enter
  6. -
  7. Wait a few seconds - it'll set everything up automatically! ✨
  8. -
-
-
- export HACKATIME_API_KEY="<%= @current_user_api_key %>" && export HACKATIME_API_URL="<%= api_hackatime_v1_url %>" && export SUCCESS_URL="<%= root_url %>/success.txt" && curl -sSL <%= root_url %>hackatime/setup.sh | bash - -
-
- -
- -
- - -
+
+

⚙️ Custom Setup:

+
+

For advanced users who want to manually configure their setup or have specific requirements.

+

Create or edit ~/.wakatime.cfg with the following content:

-
@@ -111,38 +46,7 @@
diff --git a/app/views/users/wakatime_setup_step_4.html.erb b/app/views/users/wakatime_setup_step_4.html.erb deleted file mode 100644 index 350131c5..00000000 --- a/app/views/users/wakatime_setup_step_4.html.erb +++ /dev/null @@ -1,62 +0,0 @@ -
-
-
-

Hackatime Setup

-
-
- - - -
-
-
- - - -
-
-
- - - -
-
-
- - - -
-
-
- -
-

🎉 Setup Complete!

-

- <%= @no_instruction_wording %> You're all set! -

-
- -
-
- -
-
- -
- <%= link_to my_wakatime_setup_step_2_path, class: "bg-secondary hover:bg-darkless text-white px-6 py-3 rounded-lg font-semibold transition-colors" do %> - Set up another editor - <% end %> - - <% if (url = session.dig(:return_data, "url")) %> - <%= link_to url, class: "bg-primary hover:bg-red text-white px-8 py-3 rounded-lg font-semibold transition-colors text-lg" do %> - <%= session.dig(:return_data, "button_text") || "Done" %> - <% end %> - <% else %> - <%= link_to root_path, class: "bg-primary hover:bg-red text-white px-8 py-3 rounded-lg font-semibold transition-colors text-lg" do %> - Get Started - <% end %> - <% end %> -
-
-
diff --git a/config/routes.rb b/config/routes.rb index 1b72da11..ad15e429 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,8 +114,6 @@ def matches?(request) get "my/wakatime_setup", to: "users#wakatime_setup" get "my/wakatime_setup/step-2", to: "users#wakatime_setup_step_2" - get "my/wakatime_setup/step-3", to: "users#wakatime_setup_step_3" - get "my/wakatime_setup/step-4", to: "users#wakatime_setup_step_4" post "/sailors_log/slack/commands", to: "slack#create" post "/timedump/slack/commands", to: "slack#create" diff --git a/public/hackatime/setup.ps1 b/public/hackatime/setup.ps1 deleted file mode 100644 index 6cebe480..00000000 --- a/public/hackatime/setup.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -try { - # Create config file with API settings - $configPath = "$env:USERPROFILE\.wakatime.cfg" - # If config exists, backup - if (Test-Path $configPath) { - Write-Host "[INFO] Config file already exists, moving into ~/.wakatime.cfg.bak" - Move-Item -Path $configPath -Destination "$configPath.bak" - } - - @" -[settings] -api_url = $env:HACKATIME_API_URL -api_key = $env:HACKATIME_API_KEY -heartbeat_rate_limit_seconds = 30 -"@ | Out-File -FilePath $configPath -Force -Encoding utf8 - - Write-Host "Config file created at $configPath" - - # Verify config was created successfully - if (Test-Path $configPath) { - $config = Get-Content $configPath - $apiUrl = ($config | Select-String "api_url").ToString().Split('=')[1].Trim() - $apiKey = ($config | Select-String "api_key").ToString().Split('=')[1].Trim() - $heartbeatRate = ($config | Select-String "heartbeat_rate_limit_seconds").ToString().Split('=')[1].Trim() - - # Display verification info - Write-Host "API URL: $apiUrl" - Write-Host ("API Key: " + $apiKey.Substring(0,4) + "..." + $apiKey.Substring($apiKey.Length-4)) # Show first/last 4 chars - - # Send test heartbeat - Write-Host "Sending test heartbeat..." - $time = [Math]::Floor([decimal](Get-Date(Get-Date).ToUniversalTime()-uformat '%s')) - $heartbeat = @{ - type = 'file' - time = $time - entity = 'test.txt' - language = 'Text' - } - - $response = Invoke-RestMethod -Uri "$apiUrl/users/current/heartbeats" ` - -Method Post ` - -Headers @{Authorization="Bearer $apiKey"} ` - -ContentType 'application/json' ` - -Body "[$($heartbeat | ConvertTo-Json)]" - - Write-Host "Test heartbeat sent successfully" - - # Display ASCII art on success - Write-Host "`n" -NoNewline - Write-Host " _ _ _ _ _ " -ForegroundColor Cyan - Write-Host " | | | | __ _ ___| | ____ _| |_(_)_ __ ___ ___ " -ForegroundColor Cyan - Write-Host " | |_| |/ _` |/ __| |/ / _` | __| | '_ ` _ \ / _ \" -ForegroundColor Cyan - Write-Host " | _ | (_| | (__| < (_| | |_| | | | | | | __/" -ForegroundColor Cyan - Write-Host " |_| |_|\__,_|\___|_|\_\__,_|\__|_|_| |_| |_|\___|" -ForegroundColor Cyan - Write-Host "`n Ready to track! " -ForegroundColor Green - Write-Host " https://hackatime.hackclub.com " -ForegroundColor Yellow - Write-Host "`n" - } else { - throw "Failed to create config file" - } -} catch { - Write-Host "----------------------------------------" - Write-Host "ERROR: An error occurred during setup:" -ForegroundColor Red - Write-Host $_.Exception.Message -ForegroundColor Red - Write-Host "----------------------------------------" -} -finally { - Write-Host "Press any key to exit..." - $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') -} diff --git a/public/hackatime/setup.sh b/public/hackatime/setup.sh deleted file mode 100644 index 9a37edca..00000000 --- a/public/hackatime/setup.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -set -e - -# If config exists, backup -if [ -f ~/.wakatime.cfg ]; then - echo "[INFO] Config file already exists, moving into ~/.wakatime.cfg.bak" - mv ~/.wakatime.cfg ~/.wakatime.cfg.bak -fi - -# Create or update config file -cat > ~/.wakatime.cfg << EOL -[settings] -api_url = ${HACKATIME_API_URL} -api_key = ${HACKATIME_API_KEY} -heartbeat_rate_limit_seconds = 30 -EOL - -echo "Config file created at ~/.wakatime.cfg" - -# Read values from config to verify -if [ ! -f ~/.wakatime.cfg ]; then - echo "Error: Config file not found" - exit 1 -fi - -API_URL=$(sed -n 's/.*api_url = \(.*\)/\1/p' ~/.wakatime.cfg) -API_KEY=$(sed -n 's/.*api_key = \(.*\)/\1/p' ~/.wakatime.cfg) -HEARTBEAT_RATE_LIMIT=$(sed -n 's/.*heartbeat_rate_limit_seconds = \(.*\)/\1/p' ~/.wakatime.cfg) - -if [ -z "$API_URL" ] || [ -z "$API_KEY" ] || [ -z "$HEARTBEAT_RATE_LIMIT" ]; then - echo "Error: Could not read api_url, api_key, or heartbeat_rate_limit_seconds from config" - exit 1 -fi - -echo "Successfully read config:" -echo "API URL: $API_URL" -echo "API Key: ${API_KEY:0:8}..." # Show only first 8 chars for security - -# Send test heartbeat using values from config -echo "Sending test heartbeat..." -response=$(curl -s -w "\n%{http_code}" -X POST "$API_URL/users/current/heartbeats" \ - -H "Authorization: Bearer $API_KEY" \ - -H "Content-Type: application/json" \ - -d "[{\"type\":\"file\",\"time\":$(date +%s),\"entity\":\"test.txt\",\"language\":\"Text\"}]") - -http_code=$(echo "$response" | tail -n1) -body=$(echo "$response" | sed '$d') - -if [ "$http_code" = "200" ] || [ "$http_code" = "202" ]; then - curl "$SUCCESS_URL" - echo -e "\nTest heartbeat sent successfully" -else - echo -e "\nError sending heartbeat: $body" - exit 1 -fi