Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN apt-get update -qq && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install standalone Tailwind CSS CLI
ARG TAILWINDCSS_VERSION=4.1.8
ARG TAILWINDCSS_VERSION=4.3.3
RUN curl -fsSL "https://github.com/tailwindlabs/tailwindcss/releases/download/v${TAILWINDCSS_VERSION}/tailwindcss-linux-x64" -o /usr/local/bin/tailwindcss && \
chmod +x /usr/local/bin/tailwindcss

Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -545,16 +545,16 @@ GEM
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.2.0)
tailwindcss-rails (4.4.0)
tailwindcss-rails (4.6.0)
railties (>= 7.0.0)
tailwindcss-ruby (~> 4.0)
tailwindcss-ruby (4.1.18)
tailwindcss-ruby (4.1.18-aarch64-linux-gnu)
tailwindcss-ruby (4.1.18-aarch64-linux-musl)
tailwindcss-ruby (4.1.18-arm64-darwin)
tailwindcss-ruby (4.1.18-x86_64-darwin)
tailwindcss-ruby (4.1.18-x86_64-linux-gnu)
tailwindcss-ruby (4.1.18-x86_64-linux-musl)
tailwindcss-ruby (4.3.3)
tailwindcss-ruby (4.3.3-aarch64-linux-gnu)
tailwindcss-ruby (4.3.3-aarch64-linux-musl)
tailwindcss-ruby (4.3.3-arm64-darwin)
tailwindcss-ruby (4.3.3-x86_64-darwin)
tailwindcss-ruby (4.3.3-x86_64-linux-gnu)
tailwindcss-ruby (4.3.3-x86_64-linux-musl)
thor (1.4.0)
thruster (0.1.17)
thruster (0.1.17-aarch64-linux)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Discover Bosnia and Herzegovina. A tourism platform featuring curated locations,
- **RubyLLM** for AI content generation
- **Kamal** for deployment

## Supported browsers

Usput works on iOS 15.4 and later, and on Android phones whose browser still
updates: Chrome and Android WebView 99, Samsung Internet 18, Firefox 115, and
the desktop versions of the same. Older browsers still get the pages, rendered
on the server, with a notice that the map, plans and check-ins need a newer
browser. Why the floor sits there: `wiki/decisions/support-phones-from-ios-15.md`.

## Quick Start

```bash
Expand Down
4 changes: 2 additions & 2 deletions app/assets/builds/tailwind.css

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions app/javascript/controllers/add_to_plan_controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Controller } from "@hotwired/stimulus"
import { escapeHtml } from "services/html_escape"
import { storage } from "services/safe_storage"

export default class extends Controller {
static targets = ["addButton", "noplanMessage", "hasplanMessage", "feedback", "planSelector"]
Expand All @@ -22,27 +23,27 @@ export default class extends Controller {

loadPlans() {
try {
const data = localStorage.getItem(this.plansKeyValue)
const data = storage.getItem(this.plansKeyValue)
if (data) {
this.allPlans = JSON.parse(data)
} else {
// Migrate from old single-plan format
const oldPlan = localStorage.getItem("visitumo_plan")
const oldPlan = storage.getItem("visitumo_plan")
if (oldPlan) {
const plan = JSON.parse(oldPlan)
this.allPlans = [plan]
// Save in new format
localStorage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))
localStorage.setItem(this.activePlanKeyValue, plan.id)
storage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))
storage.setItem(this.activePlanKeyValue, plan.id)
// Clean up old format
localStorage.removeItem("visitumo_plan")
storage.removeItem("visitumo_plan")
} else {
this.allPlans = []
}
}

// Get active plan ID
this.selectedPlanId = localStorage.getItem(this.activePlanKeyValue)
this.selectedPlanId = storage.getItem(this.activePlanKeyValue)
if (!this.selectedPlanId && this.allPlans.length > 0) {
this.selectedPlanId = this.allPlans[0].id
}
Expand Down Expand Up @@ -151,7 +152,7 @@ export default class extends Controller {
if (planIndex !== -1) {
this.allPlans[planIndex] = plan
}
localStorage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))
storage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))

const planName = plan.city?.display_name || plan.city?.name || 'plan'
this.showFeedback(`Iskustvo je dodano u "${planName}"!`, "success")
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/controllers/audio_tour_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from "@hotwired/stimulus"
import { storage } from "services/safe_storage"

// Audio Tour controller for multilingual audio playback with custom player controls
// Allows users to switch between different language versions of audio tours
Expand Down Expand Up @@ -209,7 +210,7 @@ export default class extends Controller {
// Save preferred language to localStorage
savePreferredLanguage(locale) {
try {
localStorage.setItem("audio_tour_locale", locale)
storage.setItem("audio_tour_locale", locale)
} catch (e) {
// localStorage not available, ignore
}
Expand All @@ -218,7 +219,7 @@ export default class extends Controller {
// Load and apply preferred language
loadPreferredLanguage() {
try {
const savedLocale = localStorage.getItem("audio_tour_locale")
const savedLocale = storage.getItem("audio_tour_locale")
if (savedLocale && this.audioUrlsValue && this.audioUrlsValue[savedLocale]) {
// Find the button for the saved locale and click it
const button = this.languageButtonTargets.find(b => b.dataset.locale === savedLocale)
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/controllers/cookie_consent_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from "@hotwired/stimulus"
import { storage } from "services/safe_storage"

// Connects to data-controller="cookie-consent"
export default class extends Controller {
Expand Down Expand Up @@ -46,8 +47,8 @@ export default class extends Controller {

saveConsent(value) {
try {
localStorage.setItem(this.storageKeyValue, value)
localStorage.setItem(`${this.storageKeyValue}_date`, new Date().toISOString())
storage.setItem(this.storageKeyValue, value)
storage.setItem(`${this.storageKeyValue}_date`, new Date().toISOString())
} catch (e) {
// localStorage might be disabled
console.warn("Could not save cookie consent preference:", e)
Expand All @@ -56,7 +57,7 @@ export default class extends Controller {

get hasConsent() {
try {
const consent = localStorage.getItem(this.storageKeyValue)
const consent = storage.getItem(this.storageKeyValue)
return consent === "accepted" || consent === "declined"
} catch (e) {
// localStorage might be disabled
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/controllers/deck_filters_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from "@hotwired/stimulus"
import { session } from "services/safe_storage"

// Filters apply on selection, with no Apply button — and a second press on an
// active choice clears it, which a radio cannot do on its own.
Expand All @@ -9,14 +10,14 @@ export default class extends Controller {
// Each pick swaps this panel out for a fresh one, so whether it was open has to
// outlive the swap — otherwise every filter costs a re-open.
connect() {
if (this.hasPanelTarget && sessionStorage.getItem(this.constructor.OPEN_KEY) === "1") {
if (this.hasPanelTarget && session.getItem(this.constructor.OPEN_KEY) === "1") {
this.panelTarget.classList.remove("hidden")
}
}

toggle() {
this.panelTarget.classList.toggle("hidden")
sessionStorage.setItem(this.constructor.OPEN_KEY, this.panelTarget.classList.contains("hidden") ? "0" : "1")
session.setItem(this.constructor.OPEN_KEY, this.panelTarget.classList.contains("hidden") ? "0" : "1")
}

// The input is sr-only, so the pointer lands on the styled span. Handling the
Expand Down
11 changes: 6 additions & 5 deletions app/javascript/controllers/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
import { positionService } from "services/position_service"
import { distanceKm, profileFor, summarise, fetchRoute } from "services/route_service"
import { loadLeaflet } from "services/leaflet_service"
import { session } from "services/safe_storage"

// Assigned by the first build on the page, and read by every method below —
// all of which run downstream of one.
Expand Down Expand Up @@ -38,13 +39,13 @@ function catalogue(version, { fresh = false } = {}) {
catalogueVersion = version

const key = `usput_map_points/${version}`
const held = fresh ? null : sessionStorage.getItem(key)
const held = fresh ? null : session.getItem(key)
if (held) {
try {
cataloguePromise = Promise.resolve(JSON.parse(held))
return cataloguePromise
} catch {
sessionStorage.removeItem(key)
session.removeItem(key)
}
}

Expand All @@ -61,8 +62,8 @@ function catalogue(version, { fresh = false } = {}) {
try {
Object.keys(sessionStorage)
.filter((held) => held.startsWith("usput_map_points/") && held !== key)
.forEach((stale) => sessionStorage.removeItem(stale))
sessionStorage.setItem(key, JSON.stringify(points))
.forEach((stale) => session.removeItem(stale))
session.setItem(key, JSON.stringify(points))
} catch {
// A full quota is not a reason to lose the map.
}
Expand Down Expand Up @@ -93,7 +94,7 @@ function forgetCatalogue() {
try {
Object.keys(sessionStorage)
.filter((key) => key.startsWith("usput_map_points/"))
.forEach((key) => sessionStorage.removeItem(key))
.forEach((key) => session.removeItem(key))
} catch {
// Storage the browser will not hand over holds nothing to forget.
}
Expand Down
21 changes: 11 additions & 10 deletions app/javascript/controllers/my_plans_controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from "@hotwired/stimulus"
import { storage } from "services/safe_storage"

export default class extends Controller {
static targets = ["container", "empty", "list"]
Expand Down Expand Up @@ -26,18 +27,18 @@ export default class extends Controller {

getPlans() {
try {
const data = localStorage.getItem(this.plansKeyValue)
const data = storage.getItem(this.plansKeyValue)
if (data) {
return JSON.parse(data)
}

// Migrate from old format
const oldPlan = localStorage.getItem("visitumo_plan")
const oldPlan = storage.getItem("visitumo_plan")
if (oldPlan) {
const plan = JSON.parse(oldPlan)
const plans = [plan]
localStorage.setItem(this.plansKeyValue, JSON.stringify(plans))
localStorage.removeItem("visitumo_plan")
storage.setItem(this.plansKeyValue, JSON.stringify(plans))
storage.removeItem("visitumo_plan")
return plans
}

Expand Down Expand Up @@ -85,7 +86,7 @@ export default class extends Controller {
renderPlans(plans) {
if (!this.hasListTarget) return

const activePlanId = localStorage.getItem(this.activePlanKeyValue)
const activePlanId = storage.getItem(this.activePlanKeyValue)

this.listTarget.innerHTML = plans.map(plan => {
const isActive = plan.id === activePlanId
Expand Down Expand Up @@ -205,7 +206,7 @@ export default class extends Controller {
setActivePlan(event) {
const planId = event.currentTarget.dataset.planId
if (planId) {
localStorage.setItem(this.activePlanKeyValue, planId)
storage.setItem(this.activePlanKeyValue, planId)
}
}

Expand Down Expand Up @@ -244,15 +245,15 @@ export default class extends Controller {
}

plans = plans.filter(p => p.id !== planId)
localStorage.setItem(this.plansKeyValue, JSON.stringify(plans))
storage.setItem(this.plansKeyValue, JSON.stringify(plans))

// Update active plan if needed
const activePlanId = localStorage.getItem(this.activePlanKeyValue)
const activePlanId = storage.getItem(this.activePlanKeyValue)
if (activePlanId === planId) {
if (plans.length > 0) {
localStorage.setItem(this.activePlanKeyValue, plans[0].id)
storage.setItem(this.activePlanKeyValue, plans[0].id)
} else {
localStorage.removeItem(this.activePlanKeyValue)
storage.removeItem(this.activePlanKeyValue)
}
}

Expand Down
23 changes: 12 additions & 11 deletions app/javascript/controllers/plan_viewer_controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Controller } from "@hotwired/stimulus"
import { planSyncService } from "services/plan_sync_service"
import { escapeHtml } from "services/html_escape"
import { storage } from "services/safe_storage"

export default class extends Controller {
static targets = [
Expand Down Expand Up @@ -121,7 +122,7 @@ export default class extends Controller {
const planId = urlParams.get('id')
if (planId) {
// Set this plan as active before loading
localStorage.setItem(this.activePlanKeyValue, planId)
storage.setItem(this.activePlanKeyValue, planId)
}
}

Expand Down Expand Up @@ -152,16 +153,16 @@ export default class extends Controller {

loadPlans() {
try {
const plansData = localStorage.getItem(this.plansKeyValue)
const plansData = storage.getItem(this.plansKeyValue)
let parsedPlans = []

if (plansData) {
try {
parsedPlans = JSON.parse(plansData)
} catch (parseError) {
console.error("Failed to parse plans from localStorage, clearing corrupted data:", parseError)
localStorage.removeItem(this.plansKeyValue)
localStorage.removeItem(this.activePlanKeyValue)
storage.removeItem(this.plansKeyValue)
storage.removeItem(this.activePlanKeyValue)
}
}

Expand All @@ -176,18 +177,18 @@ export default class extends Controller {

// Migrate from old single-plan format if needed
if (this.allPlans.length === 0) {
const oldPlan = localStorage.getItem("visitumo_plan")
const oldPlan = storage.getItem("visitumo_plan")
if (oldPlan) {
try {
const plan = JSON.parse(oldPlan)
if (this.isValidPlan(plan)) {
this.allPlans = [plan]
this.savePlans()
localStorage.removeItem("visitumo_plan")
storage.removeItem("visitumo_plan")
}
} catch (e) {
console.error("Failed to migrate old plan format:", e)
localStorage.removeItem("visitumo_plan")
storage.removeItem("visitumo_plan")
}
}
}
Expand All @@ -198,7 +199,7 @@ export default class extends Controller {
}

// Get active plan ID
const activePlanId = localStorage.getItem(this.activePlanKeyValue)
const activePlanId = storage.getItem(this.activePlanKeyValue)
let activePlan = null

if (activePlanId) {
Expand Down Expand Up @@ -234,7 +235,7 @@ export default class extends Controller {

savePlans() {
try {
localStorage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))
storage.setItem(this.plansKeyValue, JSON.stringify(this.allPlans))

// Also sync to backend if logged in (debounced)
if (planSyncService.isLoggedIn()) {
Expand All @@ -256,7 +257,7 @@ export default class extends Controller {
}

setActivePlan(planId) {
localStorage.setItem(this.activePlanKeyValue, planId)
storage.setItem(this.activePlanKeyValue, planId)
}

switchPlan(event) {
Expand Down Expand Up @@ -774,7 +775,7 @@ export default class extends Controller {
this.loadRecommendations()
} else {
// No more plans
localStorage.removeItem(this.activePlanKeyValue)
storage.removeItem(this.activePlanKeyValue)
this.currentPlan = null
this.showEmpty()
}
Expand Down
Loading