This repository has no description
0

Configure Feed

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

bookmarker / lib / bookmarker_web.ex
2.6 kB 118 lines
1defmodule BookmarkerWeb do 2 @moduledoc """ 3 The entrypoint for defining your web interface, such 4 as controllers, components, channels, and so on. 5 6 This can be used in your application as: 7 8 use BookmarkerWeb, :controller 9 use BookmarkerWeb, :html 10 11 The definitions below will be executed for every controller, 12 component, etc, so keep them short and clean, focused 13 on imports, uses and aliases. 14 15 Do NOT define functions inside the quoted expressions 16 below. Instead, define additional modules and import 17 those modules here. 18 """ 19 20 def static_paths, do: ~w(assets fonts images favicon.ico robots.txt) 21 22 def router do 23 quote do 24 use Phoenix.Router, helpers: false 25 26 # Import common connection and controller functions to use in pipelines 27 import Plug.Conn 28 import Phoenix.Controller 29 import Phoenix.LiveView.Router 30 end 31 end 32 33 def channel do 34 quote do 35 use Phoenix.Channel 36 end 37 end 38 39 def controller do 40 quote do 41 use Phoenix.Controller, 42 formats: [:html, :json], 43 layouts: [html: BookmarkerWeb.Layouts] 44 45 use Gettext, backend: BookmarkerWeb.Gettext 46 47 import Plug.Conn 48 49 unquote(verified_routes()) 50 end 51 end 52 53 def live_view do 54 quote do 55 use Phoenix.LiveView, 56 layout: {BookmarkerWeb.Layouts, :app} 57 58 unquote(html_helpers()) 59 end 60 end 61 62 def live_component do 63 quote do 64 use Phoenix.LiveComponent 65 66 unquote(html_helpers()) 67 end 68 end 69 70 def html do 71 quote do 72 use Phoenix.Component 73 74 # Import convenience functions from controllers 75 import Phoenix.Controller, 76 only: [get_csrf_token: 0, view_module: 1, view_template: 1] 77 78 # Include general helpers for rendering HTML 79 unquote(html_helpers()) 80 end 81 end 82 83 defp html_helpers do 84 quote do 85 # Translation 86 use Gettext, backend: BookmarkerWeb.Gettext 87 88 # HTML escaping functionality 89 import Phoenix.HTML 90 # Core UI components 91 import BookmarkerWeb.CoreComponents 92 # Form helpers 93 import Phoenix.HTML.Form 94 95 # Shortcut for generating JS commands 96 alias Phoenix.LiveView.JS 97 98 # Routes generation with the ~p sigil 99 unquote(verified_routes()) 100 end 101 end 102 103 def verified_routes do 104 quote do 105 use Phoenix.VerifiedRoutes, 106 endpoint: BookmarkerWeb.Endpoint, 107 router: BookmarkerWeb.Router, 108 statics: BookmarkerWeb.static_paths() 109 end 110 end 111 112 @doc """ 113 When used, dispatch to the appropriate controller/live_view/etc. 114 """ 115 defmacro __using__(which) when is_atom(which) do 116 apply(__MODULE__, which, []) 117 end 118end