Skip to content

Instantly share code, notes, and snippets.

View Allyedge's full-sized avatar
Grinding

Allyedge Allyedge

Grinding
View GitHub Profile
defmodule MoviesWeb.Router do
use MoviesWeb, :router
pipeline :browser do
plug(:accepts, ["html"])
plug(:fetch_session)
plug(:fetch_live_flash)
plug(:put_root_layout, {MoviesWeb.Layouts, :root})
plug(:protect_from_forgery)
plug(:put_secure_browser_headers)
import "phoenix_html";
// Establish Phoenix Socket and LiveView configuration.
import { Socket } from "phoenix";
import { LiveSocket } from "phoenix_live_view";
import topbar from "../vendor/topbar";
import InfiniteScroll from "./pagination/infinite_scroll";
let Hooks = {};
Hooks.InfiniteScroll = InfiniteScroll;
defp deps do
[
{:phoenix, "~> 1.7.1"},
{:phoenix_html, "~> 3.3"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.18.16"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.7.2"},
{:esbuild, "~> 0.5", runtime: Mix.env() == :dev},
{:tailwind, "~> 0.1.8", runtime: Mix.env() == :dev},
defmodule Movies.MovieItem do
def search(query) do
response =
HTTPoison.post!("http://localhost:7700/indexes/movies/search", Jason.encode!(%{q: query}), [
{"Content-Type", "application/json"}
])
body = Jason.decode!(response.body)
hits = body["hits"]
defmodule MoviesWeb.MovieItemLive.Index do
use MoviesWeb, :live_view
alias Movies.MovieItem
@impl true
def mount(_params, _session, socket) do
result = MovieItem.search("")
{:ok,
defmodule AllychatWeb.ChatLive do
use AllychatWeb, :live_view
def mount(_params, _session, socket) do
{:ok, socket}
end
def render(assigns) do
~H"""
<h1>Chat</h1>
scope "/", AllychatWeb do
pipe_through :browser
live "/", ChatLive
end
scope "/", AllychatWeb do
pipe_through :browser
get "/", PageController, :index
end
html,
body {
background-color: #181c25;
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {