-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So that we can show line numbers.
- Loading branch information
Showing
7 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ | |
{%- endblock css %} | ||
|
||
{% block headjs -%} | ||
<script src='https://unpkg.com/alpinejs' defer></script> | ||
<script src='https://unpkg.com/[email protected]/dist/htmx.min.js' defer></script> | ||
{%- endblock headjs %} | ||
{%- endblock head %} | ||
|
@@ -78,9 +77,45 @@ | |
get created_at_full_display() { | ||
return this.created_at ? longFormatter.format(this.created_at) : '' | ||
}, | ||
})) | ||
})); | ||
}) | ||
</script> | ||
<script type='module'> | ||
import { codeToHtml } from 'https://esm.sh/[email protected]' | ||
document.addEventListener('alpine:init', () => { | ||
Alpine.data('need_highlight', () => ({ | ||
code: '', | ||
lang: 'text', | ||
init() { | ||
const codeElm = this.$refs.orig_code; | ||
const code = codeElm.textContent | ||
this.code = code.trim() | ||
let className = Array.from(codeElm.classList.values()).find((c) => c.startsWith('language-')) | ||
if (className) { | ||
this.lang = className.split('-')[1] | ||
} | ||
}, | ||
async highlight() { | ||
const html = await codeToHtml(this.code, { lang: this.lang, theme: 'one-dark-pro' }) | ||
return html | ||
} | ||
})) | ||
}) | ||
</script> | ||
{%- endblock js %} | ||
<script type='module'> | ||
// There are pages which only have tiny apps defined directly in HTML markup, without any | ||
// <script type='module'> block. We need to load Alpine to activate those apps too. | ||
import Alpine from "https://esm.sh/[email protected]" | ||
if (!window.Alpine) { | ||
window.Alpine = Alpine | ||
} | ||
if (window.Alpine) { | ||
console.log('Start tiny apps') | ||
window.Alpine.start() | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
use syntect::html::ClassStyle; | ||
|
||
|
||
pub const DB_NAME: &str = "quanweb"; | ||
pub const DEFAULT_PAGE_SIZE: u8 = 10; | ||
pub const STATIC_URL: &str = "/static"; | ||
pub const UNCATEGORIZED_URL: &str = "/category/_uncategorized/"; | ||
pub const SYNTECT_CLASS_STYLE: ClassStyle = ClassStyle::SpacedPrefixed { prefix: "st-" }; | ||
pub const KEY_LANG: &str = "lang"; | ||
pub const DEFAULT_LANG: &str = "en"; | ||
pub const ALPINE_HIGHLIGHTING_APP: &str = "need_highlight"; | ||
pub const ALPINE_ORIG_CODE_ELM: &str = "orig_code"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters