Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve SEO #570

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
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
26 changes: 26 additions & 0 deletions lib/atomic_web/controllers/sitemap_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defmodule AtomicWeb.Controllers.SitemapController do
use AtomicWeb, :controller

def index(conn, _params) do
urls = [
"https://domain.com/",
"https://domain.com/activities",
"https://domain.com/organizations",
"https://domain.com/announcements",
"https://domain.com/tos",
"https://domain.com/privacy",
"https://domain.com/cookies"
]

xml = """
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
#{Enum.map_join(urls, "\n", fn url -> "<url><loc>#{url}</loc></url>" end)}
</urlset>
"""

conn
|> put_resp_content_type("application/xml")
|> send_resp(200, xml)
end
end
1 change: 1 addition & 0 deletions lib/atomic_web/live/activity_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule AtomicWeb.ActivityLive.Index do
{:noreply,
socket
|> assign(:page_title, gettext("Activities"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :activities)
|> assign(:current_tab, current_tab(socket, params))
|> assign(:params, params)
Expand Down
3 changes: 3 additions & 0 deletions lib/atomic_web/live/activity_live/index.html.heex
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<title>{gettext("Atomic - Activities")}</title>
<meta name="description" content={gettext("Many activities")} />

<.page title="Activities">
<:actions>
<.button navigate={~p"/organizations/#{@organization}/activities/new"}>
Expand Down
92 changes: 92 additions & 0 deletions lib/atomic_web/live/activity_live/map.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<title>{gettext("Atomic - Activities")}</title>
<meta name="description" content={gettext("Many activities")} />

<.page title="Activities">
<:actions>
<.button navigate={~p"/organizations/#{@organization}/activities/new"}>
{gettext("New")}
</.button>
</:actions>
<!-- Tabs -->
<.tabs class="max-w-5-xl mx-auto px-4 sm:px-6 lg:px-8">
<.link patch="?tab=all" replace={false}>
<.tab active={@current_tab == "all"}>
{gettext("All")}
</.tab>
</.link>

<.link patch="?tab=following" replace={false}>
<.tab active={@current_tab == "following"}>
{gettext("Following")}
</.tab>
</.link>

<.link patch="?tab=upcoming" replace={false}>
<.tab active={@current_tab == "upcoming"}>
{gettext("Upcoming")}
</.tab>
</.link>

<.link patch="?tab=enrolled" replace={false}>
<.tab active={@current_tab == "enrolled"}>
{gettext("Enrolled")}
</.tab>
</.link>
</.tabs>
<!-- Activities index -->
<%= if @empty? and @has_permissions? do %>
<div class="mt-32">
<.empty_state url={~p"/organizations/#{@organization}/activities/new"} placeholder="activity" />
</div>
<% else %>
<div class="overflow-hidden bg-white">
<ul role="list" class="divide-y divide-zinc-200 overflow-auto">
<%= for activity <- @activities do %>
<li id={activity.id}>
<.link navigate={~p"/activities/#{activity}"} class="block hover:bg-zinc-50">
<div class="px-4 py-4 lg:px-6">
<div class="flex items-center justify-between">
<p class="truncate text-sm font-medium text-zinc-900">
{activity.title}
</p>
</div>
<div class="mt-2 lg:flex lg:justify-between">
<div class="lg:flex lg:space-x-3">
<p class="mt-2 flex items-center text-sm text-zinc-500 lg:mt-0">
<.icon name="hero-users-solid" class="mr-1.5 h-5 w-5 flex-shrink-0 text-zinc-400" />
{Enum.count(activity.enrollments)} / {activity.maximum_entries}
</p>
<p class="mt-2 flex items-center text-sm text-zinc-500 lg:mt-0">
<.icon name="hero-calendar-solid" class="mr-1.5 h-5 w-5 flex-shrink-0 text-zinc-400" />
<%= if activity.start do %>
{display_date(activity.start)}
<% end %>
</p>
<%= if activity.location do %>
<p class="mt-2 flex items-center text-sm text-zinc-500 lg:mt-0">
<.icon name="hero-map-pin-solid" class="mr-1.5 h-5 w-5 flex-shrink-0 text-zinc-400" />
{activity.location && activity.location.name}
</p>
<% end %>
</div>
</div>
<div class="flex flex-col-reverse lg:flex-row-reverse lg:items-center lg:justify-between">
<%= if Activities.verify_maximum_enrollments?(activity.id) do %>
<div class="mt-2 flex items-center text-sm text-zinc-500 lg:mt-0">
<.icon name="hero-bell-solid" class="mr-1.5 h-5 w-5 flex-shrink-0 text-zinc-400" /> Open
</div>
<% else %>
<div class="mt-2 flex items-center text-sm text-zinc-500 lg:mt-0">
<.icon name="hero-bell-solid" class="mr-1.5 h-5 w-5 flex-shrink-0 text-zinc-400" /> Closed
</div>
<% end %>
</div>
</div>
</.link>
</li>
<% end %>
</ul>
<.pagination items={@activities} meta={@meta} params={@params} class="mt-2 flex w-full items-center justify-between" />
</div>
<% end %>
</.page>
1 change: 1 addition & 0 deletions lib/atomic_web/live/announcement_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defmodule AtomicWeb.AnnouncementLive.Index do
{:noreply,
socket
|> assign(:page_title, gettext("Announcements"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :announcements)
|> assign(:organization, organization)
|> assign(:params, params)
Expand Down
1 change: 1 addition & 0 deletions lib/atomic_web/live/calendar_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule AtomicWeb.CalendarLive.Show do
{:noreply,
socket
|> assign(:page_title, gettext("Calendar"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :calendar)
|> assign(:params, params)
|> assign(:mode, mode)
Expand Down
1 change: 1 addition & 0 deletions lib/atomic_web/live/department_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ defmodule AtomicWeb.DepartmentLive.Index do
{:noreply,
socket
|> assign(:page_title, "#{organization.name}'s #{gettext("Departments")}")
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :departments)
|> assign(:organization, organization)
|> assign(:departments, departments)
Expand Down
1 change: 1 addition & 0 deletions lib/atomic_web/live/home_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ defmodule AtomicWeb.HomeLive.Index do
socket
|> assign(:current_page, :home)
|> assign(:page_title, gettext("Home"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:schedule_default, fetch_default_schedule())
|> assign(:schedule_user, fetch_user_schedule(socket.assigns.current_user))
|> assign(:current_tab, current_tab(socket, params))
Expand Down
3 changes: 2 additions & 1 deletion lib/atomic_web/live/legal_terms_live/cookies_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule AtomicWeb.CookiesLive.Show do
{:noreply,
socket
|> assign(:current_page, :cookies)
|> assign(:page_title, gettext("Cookie Policy"))}
|> assign(:page_title, gettext("Cookie Policy"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))}
end
end
1 change: 1 addition & 0 deletions lib/atomic_web/live/organization_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defmodule AtomicWeb.OrganizationLive.Index do
{:noreply,
socket
|> assign(:page_title, gettext("Organizations"))
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :organizations)
|> assign(:params, params)
|> assign(organizations_with_flop)
Expand Down
1 change: 1 addition & 0 deletions lib/atomic_web/live/partner_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule AtomicWeb.PartnerLive.Index do
{:noreply,
socket
|> assign(:page_title, "#{organization.name}'s #{gettext("Partners")}")
|> assign(:page_description, gettext("Lorem ipsum jonas dolor"))
|> assign(:current_page, :partners)
|> assign(:params, params)
|> assign(:current_tab, current_tab(socket, params))
Expand Down
4 changes: 4 additions & 0 deletions lib/atomic_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,8 @@ defmodule AtomicWeb.Router do
live_dashboard "/dashboard", metrics: AtomicWeb.Telemetry
end
end

scope "/", AtomicWeb do
get "/sitemap.xml", Controllers.SitemapController, :index
end
end
36 changes: 32 additions & 4 deletions priv/static/robots.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

User-agent: *
# Admin routes
Disallow: /organizations/new
Disallow: /organizations/*/edit
Disallow: /activities/*/edit
Disallow: /announcements/*/edit
Disallow: /departments/*/edit
Disallow: /partners/*/edit

# Authentication and account management
Disallow: /users/
Disallow: /users/register
Disallow: /users/log_in
Disallow: /users/log_out
Disallow: /users/reset_password
Disallow: /users/change_password
Disallow: /users/setup
Disallow: /users/confirm
Disallow: /users/confirm_email/*

# Tools
Disallow: /scanner/
Disallow: /storybook/
Disallow: /dev/
Disallow: /dashboard/
Disallow: /mailbox/

Disallow: /*?*
Allow: /
Sitemap: https://domain.com/sitemap.xml
Crawl-delay: 10
Loading