7 Commits

  1. 21
      CHANGELOG.md
  2. 8
      assets/css/app.scss
  3. 20
      assets/js/app.js
  4. 32
      assets/js/hooks.js
  5. 2
      lib/mirage_web/live/note_live/show.ex
  6. 6
      lib/mirage_web/live/search_live/index.html.leex
  7. 4
      lib/mirage_web/templates/layout/root.html.leex
  8. 2
      mix.exs

21
CHANGELOG.md

@ -5,6 +5,27 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.85.0](https://git.inhji.de/inhji/mirage/compare/v0.84.0...v0.85.0) (2021-03-23)
### Features:
* autofocus for search input, closes #45
* slight border around note images, closes #43
* remove left margin on body when logged out, closes #46
* absolute favicon.ico path, closes #44
### Bug Fixes:
* clean up js
* allow gif and png in upload form
## [v0.84.0](https://git.inhji.de/inhji/mirage/compare/v0.83.0...v0.84.0) (2021-03-21)

8
assets/css/app.scss

@ -12,6 +12,10 @@
body {
margin-left: calc(var(--width-sidebar) + var(--ok-s-3));
&.logged-out {
margin-left: auto;
}
}
.tag a {
@ -35,6 +39,10 @@ a.button {
min-width: auto;
}
img {
border: 1px solid #dddddd;
}
textarea,
input[type=text],
input[type=email],

20
assets/js/app.js

@ -20,26 +20,16 @@ import {LiveSocket} from "phoenix_live_view"
import TableSort from "tablesort"
import EasyMDE from "easymde"
import {NoteForm, LinkForm, SettingForm, GotoAnything, onKeydown} from "./hooks"
const handledKeys = ["p"]
const Hooks = {NoteForm, LinkForm, SettingForm, GotoAnything}
import Hooks from "./hooks"
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {
params: {_csrf_token: csrfToken},
hooks: Hooks,
metadata: {keydown: (e, el) => {
if (handledKeys.includes(e.key) && e.ctrlKey)
e.preventDefault()
console.log(e)
return {
key: e.key,
ctrlKey: e.ctrlKey
}
}}
metadata: {keydown: (e, el) => ({
key: e.key,
ctrlKey: e.ctrlKey
})}
})
// Show progress bar on live navigation and form submits

32
assets/js/hooks.js

@ -1,13 +1,4 @@
export const GotoAnything = {
updated() {
if (this.el.classList.contains("open")) {
const input = document.querySelector("#query")
input.focus()
}
}
}
export const NoteForm = {
const NoteForm = {
mounted() {
if (document.querySelector("#tags")) {
import(/* webpackChunkName: "editor" */ "@yaireo/tagify").then(module => {
@ -21,14 +12,19 @@ export const NoteForm = {
}
}
export const LinkForm = NoteForm
export const SettingForm = NoteForm
export const onKeydown = (e, el) => {
if (e.ctrlKey) e.preventDefault()
const SearchForm = {
mounted() {
const queryInput = document.querySelector("#query")
return {
key: e.key,
ctrlKey: e.ctrlKey
if (queryInput) {
queryInput.focus()
}
}
}
export default {
NoteForm,
SearchForm,
LinkForm: NoteForm,
SettingForm: NoteForm,
}

2
lib/mirage_web/live/note_live/show.ex

@ -18,7 +18,7 @@ defmodule MirageWeb.NoteLive.Show do
{:ok,
socket
|> assign(:uploaded_images, [])
|> allow_upload(:image, accept: ~w(.jpg .jpeg), max_entries: 2)
|> allow_upload(:image, accept: ~w(.jpg .jpeg .gif .png), max_entries: 2)
|> with_user(session)}
end

6
lib/mirage_web/live/search_live/index.html.leex

@ -5,9 +5,11 @@
<input id="query"
type="text"
placeholder="Search for anything..."
autocomplete="off"
autocomplete="off"
phx-hook="SearchForm"
phx-keydown="search"
phx-debounce="200">
phx-debounce="200"
phx-update="ignore">
</form>
<div class="results">

4
lib/mirage_web/templates/layout/root.html.leex

@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= csrf_meta_tag() %>
<%= live_title_tag assigns[:page_title] || "Inhji.de", suffix: " · Mirage" %>
<link rel="icon" href='favicon.ico'>
<%= live_title_tag assigns[:page_title] || "Inhji.de", suffix: " · Inhji.de" %>
<link rel="icon" href="/favicon.ico">
<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
<script defer phx-track-static type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</head>

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.84.0"
@version "0.85.0"
def project do
[

Loading…
Cancel
Save