2026-02-18 21:23:15 +00:00
|
|
|
defmodule BerrypodWeb do
|
2025-12-30 12:26:26 +00:00
|
|
|
@moduledoc """
|
|
|
|
|
The entrypoint for defining your web interface, such
|
|
|
|
|
as controllers, components, channels, and so on.
|
|
|
|
|
|
|
|
|
|
This can be used in your application as:
|
|
|
|
|
|
2026-02-18 21:23:15 +00:00
|
|
|
use BerrypodWeb, :controller
|
|
|
|
|
use BerrypodWeb, :html
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
The definitions below will be executed for every controller,
|
|
|
|
|
component, etc, so keep them short and clean, focused
|
|
|
|
|
on imports, uses and aliases.
|
|
|
|
|
|
|
|
|
|
Do NOT define functions inside the quoted expressions
|
|
|
|
|
below. Instead, define additional modules and import
|
|
|
|
|
those modules here.
|
|
|
|
|
"""
|
|
|
|
|
|
2026-01-31 14:24:58 +00:00
|
|
|
def static_paths,
|
add canonical URLs, robots.txt, and sitemap.xml
Canonical: all shop pages now assign og_url (reusing the existing og:url
assign), which the layout renders as <link rel="canonical">. Collection
pages strip the sort param so ?sort=price_asc doesn't create a duplicate
canonical.
robots.txt: dynamic controller disallows /admin/, /api/, /users/,
/webhooks/, /checkout/. Removed robots.txt from static_paths so it
goes through the router instead of Plug.Static.
sitemap.xml: auto-generated from all visible products + categories +
static pages, served as application/xml. 8 tests.
Also updates PROGRESS.md: marks tasks 55, 58, 59, 61, 62 as done.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:47:35 +00:00
|
|
|
do: ~w(assets css fonts images image_cache mockups favicon.ico demo.html)
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
def router do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.Router, helpers: false
|
|
|
|
|
|
|
|
|
|
# Import common connection and controller functions to use in pipelines
|
|
|
|
|
import Plug.Conn
|
|
|
|
|
import Phoenix.Controller
|
|
|
|
|
import Phoenix.LiveView.Router
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def channel do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.Channel
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def controller do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.Controller, formats: [:html, :json]
|
|
|
|
|
|
2026-02-18 21:23:15 +00:00
|
|
|
use Gettext, backend: BerrypodWeb.Gettext
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
import Plug.Conn
|
integrate R module and add url editor ui
Replaces hardcoded paths with R module throughout:
- Shop components: layout nav, cart, product links
- Controllers: cart, checkout, contact, seo, order lookup
- Shop pages: collection, product, search, checkout success, etc.
- Site context: nav item url resolution
Admin URL management:
- Settings page: prefix editor with validation feedback
- Page renderer: url_editor component for page URLs
- CSS for url editor styling
Test updates for cache isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 00:36:17 +01:00
|
|
|
# Runtime URL paths (custom slugs/prefixes)
|
|
|
|
|
alias BerrypodWeb.R
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
unquote(verified_routes())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def live_view do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.LiveView
|
|
|
|
|
|
integrate R module and add url editor ui
Replaces hardcoded paths with R module throughout:
- Shop components: layout nav, cart, product links
- Controllers: cart, checkout, contact, seo, order lookup
- Shop pages: collection, product, search, checkout success, etc.
- Site context: nav item url resolution
Admin URL management:
- Settings page: prefix editor with validation feedback
- Page renderer: url_editor component for page URLs
- CSS for url editor styling
Test updates for cache isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 00:36:17 +01:00
|
|
|
# Enable sandbox access for LiveView processes in test mode
|
|
|
|
|
if Application.compile_env(:berrypod, :env) == :test do
|
|
|
|
|
on_mount BerrypodWeb.LiveSandboxHook
|
|
|
|
|
end
|
|
|
|
|
|
2025-12-30 12:26:26 +00:00
|
|
|
unquote(html_helpers())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def live_component do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.LiveComponent
|
|
|
|
|
|
|
|
|
|
unquote(html_helpers())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def html do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.Component
|
|
|
|
|
|
|
|
|
|
# Import convenience functions from controllers
|
|
|
|
|
import Phoenix.Controller,
|
|
|
|
|
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
|
|
|
|
|
|
|
|
|
# Include general helpers for rendering HTML
|
|
|
|
|
unquote(html_helpers())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp html_helpers do
|
|
|
|
|
quote do
|
|
|
|
|
# Translation
|
2026-02-18 21:23:15 +00:00
|
|
|
use Gettext, backend: BerrypodWeb.Gettext
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
# HTML escaping functionality
|
|
|
|
|
import Phoenix.HTML
|
|
|
|
|
# Core UI components
|
2026-02-18 21:23:15 +00:00
|
|
|
import BerrypodWeb.CoreComponents
|
2026-01-17 13:11:39 +00:00
|
|
|
# Shop UI components
|
2026-02-18 21:23:15 +00:00
|
|
|
use BerrypodWeb.ShopComponents
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
# Common modules used in templates
|
|
|
|
|
alias Phoenix.LiveView.JS
|
2026-02-18 21:23:15 +00:00
|
|
|
alias BerrypodWeb.Layouts
|
integrate R module and add url editor ui
Replaces hardcoded paths with R module throughout:
- Shop components: layout nav, cart, product links
- Controllers: cart, checkout, contact, seo, order lookup
- Shop pages: collection, product, search, checkout success, etc.
- Site context: nav item url resolution
Admin URL management:
- Settings page: prefix editor with validation feedback
- Page renderer: url_editor component for page URLs
- CSS for url editor styling
Test updates for cache isolation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-01 00:36:17 +01:00
|
|
|
# Runtime URL paths (custom slugs/prefixes)
|
|
|
|
|
alias BerrypodWeb.R
|
2025-12-30 12:26:26 +00:00
|
|
|
|
|
|
|
|
# Routes generation with the ~p sigil
|
|
|
|
|
unquote(verified_routes())
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def verified_routes do
|
|
|
|
|
quote do
|
|
|
|
|
use Phoenix.VerifiedRoutes,
|
2026-02-18 21:23:15 +00:00
|
|
|
endpoint: BerrypodWeb.Endpoint,
|
|
|
|
|
router: BerrypodWeb.Router,
|
|
|
|
|
statics: BerrypodWeb.static_paths()
|
2025-12-30 12:26:26 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
|
When used, dispatch to the appropriate controller/live_view/etc.
|
|
|
|
|
"""
|
|
|
|
|
defmacro __using__(which) when is_atom(which) do
|
|
|
|
|
apply(__MODULE__, which, [])
|
|
|
|
|
end
|
|
|
|
|
end
|