this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: remove .cgi suffix on routes

Remove cgi from search and ogpreview. note that clients that expect .cgi to be
there will still work. They are just not advertising the routes that way.

+39 -42
+2
cmd/tumble/main.go
··· 163 163 mux.HandleFunc("/", h.Index) 164 164 mux.HandleFunc("/index.cgi", h.Index) 165 165 mux.HandleFunc("/stats", h.Stats) 166 + mux.HandleFunc("/search", h.Search) 166 167 mux.HandleFunc("/search.cgi", h.Search) 167 168 mux.HandleFunc("/irclink/", h.IRCLinkHandler) // Handles /irclink/?id and posts 168 169 170 + mux.HandleFunc("/ogpreview", h.OGPreviewHandler) 169 171 mux.HandleFunc("/ogpreview.cgi", h.OGPreviewHandler) 170 172 mux.HandleFunc("/api/caching/invalidate", h.InvalidateCacheHandler) 171 173 mux.HandleFunc("/buttons/", h.ButtonHandler) // Handle /buttons/ with ButtonHandler (landing + result)
+2 -2
internal/assets/openapi.json
··· 153 153 } 154 154 } 155 155 }, 156 - "/ogpreview.cgi": { 156 + "/ogpreview": { 157 157 "get": { 158 158 "summary": "Get OpenGraph Preview", 159 159 "parameters": [ ··· 252 252 } 253 253 } 254 254 }, 255 - "/search.cgi": { 255 + "/search": { 256 256 "get": { 257 257 "summary": "Search Content", 258 258 "parameters": [
+1 -1
internal/templates/views/header.html
··· 180 180 </div> 181 181 </div> 182 182 183 - <form action="/search.cgi" method="get" style="margin: 0;"> 183 + <form action="/search" method="get" style="margin: 0;"> 184 184 <input type="text" name="search" placeholder="search..." /> 185 185 </form> 186 186
+1 -1
internal/templates/views/index.html
··· 64 64 } 65 65 66 66 // Create preview endpoint URL 67 - var previewUrl = "/ogpreview.cgi?url=" + encodeURIComponent(url); 67 + var previewUrl = "/ogpreview?url=" + encodeURIComponent(url); 68 68 69 69 // Load preview asynchronously 70 70 var xhr = new XMLHttpRequest();
+7 -4
tests/api_test.sh
··· 59 59 fi 60 60 61 61 # 3. Search (HTML) 62 - check_200 "/search.cgi?search=test" 62 + check_200 "/search?search=test" # New 63 + check_200 "/search.cgi?search=test" # Legacy 63 64 64 65 # 4. IRCLink Redirect (Setup needed for real test, checking 404/400 for bad ID) 65 66 echo -n "Checking /irclink/?id=999999 (Expect 404/Redirect)... " ··· 75 76 check_200 "/v0/" 76 77 check_200 "/v0/search.cgi?search=test" 77 78 78 - # 6. YouTube 404 Check 79 - echo -n "Checking YouTube value for missing video (Expect 200 OK + status: 404)... " 80 - resp=$(curl -s "$BASE_URL/ogpreview.cgi?url=https://www.youtube.com/watch?v=video_gone") 79 + # 6. OGPreview Routes 80 + check_200 "/ogpreview.cgi?url=https://example.com" # Legacy 81 + # YouTube 404 Check (New Route) 82 + echo -n "Checking YouTube value for missing video (Expect 200 OK + status: 404) on /ogpreview... " 83 + resp=$(curl -s "$BASE_URL/ogpreview?url=https://www.youtube.com/watch?v=video_gone") 81 84 # Check if response contains '"status": 404' (or 'status":404' depending on spacing) 82 85 if [[ "$resp" == *'"status":404'* ]] || [[ "$resp" == *'"status": 404'* ]]; then 83 86 echo "OK"
+26 -34
tests/preview_test.sh
··· 3 3 # Usage: ./tests/preview_test.sh [BASE_URL] 4 4 5 5 BASE_URL="${1:-http://localhost:8080}" 6 - ENDPOINT="$BASE_URL/ogpreview.cgi" 6 + ENDPOINT="$BASE_URL/ogpreview" 7 7 8 8 echo "Running Preview Tests against $ENDPOINT" 9 9 ··· 43 43 } 44 44 45 45 # --- REDDIT --- 46 + # --- REDDIT --- 46 47 # Valid: Should have rich metadata (provider_name or type) 47 - test_preview "Reddit Valid" 48 - "https://www.reddit.com/r/valheim/comments/leqdj6/our_first_encounter_with_the_troll/" 48 + test_preview "Reddit Valid" \ 49 + "https://www.reddit.com/r/valheim/comments/leqdj6/our_first_encounter_with_the_troll/" \ 49 50 '.provider_name == "Reddit" or .title != null' 50 51 51 52 # Invalid: specific non-existent post. 52 - # Note: Reddit might redirect 404s to search pages or return 200 with "Not Found" content, 53 - # so exact behavior is tricky. But tryOEmbed likely fails 404, scraper might find garbage or nothing. 54 - # We expect "error" or empty-ish response if strictly handled, but scraper might find "Reddit - Dive into..." title. 55 - # Let's rely on "custom" logic failing or returning generic "Reddit" title which might pass 'Valid' check? 56 - # For now, let's assume 'Invalid' means we check for absence of specific post content if possible, 57 - # OR just that it doesn't crash. But user requested testing 404 logic. 58 - # If preview_reddit.go fails, it falls back. 59 - test_preview "Reddit Invalid" 60 - "https://www.reddit.com/r/valheim/comments/INVALID_ID_12345/" 53 + test_preview "Reddit Invalid" \ 54 + "https://www.reddit.com/r/valheim/comments/INVALID_ID_12345/" \ 61 55 '.error != null or (.title | contains("Page not found") or contains("Reddit"))' 62 56 63 57 # --- SPOTIFY --- 64 58 # Valid 65 - test_preview "Spotify Valid" 66 - "https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" 59 + test_preview "Spotify Valid" \ 60 + "https://open.spotify.com/episode/7makk4oTQel546B0PZlDM5" \ 67 61 '.provider_name == "Spotify" or .type == "rich"' 68 62 69 63 70 64 # Invalid 71 - # Spotify returns a 200 OK on invalid tracks with a "Spotify - Web Player" title, 72 - # so we expect a valid scrape fallback, not an error. 73 - test_preview "Spotify Invalid" 74 - "https://open.spotify.com/track/INVALID_TRACK_ID" 65 + test_preview "Spotify Invalid" \ 66 + "https://open.spotify.com/track/INVALID_TRACK_ID" \ 75 67 '.provider_name == "Spotify"' 76 68 77 69 # --- IMGUR --- 78 70 # Valid 79 - test_preview "Imgur Valid" 80 - "https://imgur.com/only-one-jack-black-0qetp3u" 71 + test_preview "Imgur Valid" \ 72 + "https://imgur.com/only-one-jack-black-0qetp3u" \ 81 73 '.title != null' 82 74 83 75 # Invalid 84 - test_preview "Imgur Invalid" 85 - "https://imgur.com/gallery/INVALID_GALLERY_ID" 76 + test_preview "Imgur Invalid" \ 77 + "https://imgur.com/gallery/INVALID_GALLERY_ID" \ 86 78 '.error != null or (.title | contains("Imgur"))' 87 79 88 80 # --- YOUTUBE --- 89 81 # Valid 90 - test_preview "YouTube Valid" 91 - "https://www.youtube.com/watch?v=dQw4w9WgXcQ" 82 + test_preview "YouTube Valid" \ 83 + "https://www.youtube.com/watch?v=dQw4w9WgXcQ" \ 92 84 '.provider_name == "YouTube"' 93 85 94 86 # Invalid (Video Unavailable) - Special handling in preview.go returning status 404 95 - test_preview "YouTube Invalid" 96 - "https://youtu.be/Ie_Wl9eNffE" 87 + test_preview "YouTube Invalid" \ 88 + "https://youtu.be/Ie_Wl9eNffE" \ 97 89 '.status == 404 and .error == "Video Unavailable"' 98 90 99 91 # --- TWITTER --- 100 92 # Valid - Returns empty object {} on success per preview_twitter.go 101 - test_preview "Twitter Valid" 102 - "https://x.com/jcockhren/status/1229101594505097216" 93 + test_preview "Twitter Valid" \ 94 + "https://x.com/jcockhren/status/1229101594505097216" \ 103 95 '. == {}' 104 96 105 97 # Invalid - Falls back to scrape. Twitter returns a generic page title / icon. 106 - test_preview "Twitter Invalid" 107 - "https://x.com/jcockhren/status/0000000000000000000" 98 + test_preview "Twitter Invalid" \ 99 + "https://x.com/jcockhren/status/0000000000000000000" \ 108 100 '.error == "Tweet Unavailable" and .status == 404' 109 101 110 102 # --- TIKTOK --- 111 103 # Valid 112 - test_preview "TikTok Valid" 113 - "https://www.tiktok.com/@tiagogreis/video/6830059644233223429" 104 + test_preview "TikTok Valid" \ 105 + "https://www.tiktok.com/@tiagogreis/video/6830059644233223429" \ 114 106 '.provider_name == "TikTok" or .type == "video"' 115 107 116 108 117 109 # Invalid - Falls back to scrape. 118 - test_preview "TikTok Invalid" 119 - "https://www.tiktok.com/@user/video/1234567890123456789" 110 + test_preview "TikTok Invalid" \ 111 + "https://www.tiktok.com/@user/video/1234567890123456789" \ 120 112 '.title | contains("TikTok")' 121 113 122 114