Skip to content

Commit

Permalink
markdown support for cdb description
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Aug 9, 2024
1 parent 17b9e26 commit 4e77b01
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions public/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
//go:embed node_modules/codemirror/mode/xml/xml.js
//go:embed node_modules/codemirror/mode/css/css.js
//go:embed node_modules/codemirror/mode/toml/toml.js
//go:embed node_modules/marked/lib/marked.umd.js
//go:embed node_modules/dompurify/dist/purify.min.js
var Webapp embed.FS

const DefaultCss = "node_modules/bootstrap/dist/css/bootstrap.min.css"
Expand Down
4 changes: 3 additions & 1 deletion public/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
import stylisticJs from '@stylistic/eslint-plugin-js'
import stylisticJs from '@stylistic/eslint-plugin-js';

export default [
{
Expand All @@ -18,6 +18,8 @@ export default [
CodeMirror: "readonly",
Chart: "readonly",
VueDatePicker: "readonly",
DOMPurify: "readonly",
marked: "readonly",
...globals.browser
}
}
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<script src="node_modules/vue/dist/vue.global.prod.js"></script>
<script src="node_modules/vue-router/dist/vue-router.global.prod.js"></script>
{{end}}
<script src="node_modules/marked/lib/marked.umd.js"></script>
<script src="node_modules/dompurify/dist/purify.min.js"></script>
<script src="node_modules/@vuepic/vue-datepicker/dist/vue-datepicker.iife.js"></script>
<script src="node_modules/chart.js/dist/chart.umd.js"></script>
<script src="node_modules/codemirror/lib/codemirror.js"></script>
Expand Down
12 changes: 11 additions & 1 deletion public/js/components/pages/cdb/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default {
get_dependencies(this.author, this.name)
.then(d => this.deps = d[`${this.author}/${this.name}`]);
},
methods: {
markdown: function(txt) {
return DOMPurify.sanitize(marked.parse(txt));
}
},
computed: {
thumbnails: function() {
return this.pkg.screenshots.map(s => s.replaceAll("/uploads/", "/thumbnails/2/"));
Expand Down Expand Up @@ -54,7 +59,12 @@ export default {
<span v-for="tag in pkg.tags" style="margin: 2px;" class="badge bg-success">{{tag}}</span>
<hr>
<h4>Description</h4>
<pre>{{pkg.long_description || pkg.short_description}}</pre>
<div v-if="pkg.long_description">
<div v-html="markdown(pkg.long_description)"></div>
</div>
<div v-else>
<pre>{{pkg.short_description}}</pre>
</div>
<h4>Dependencies</h4>
<ul v-if="deps">
<li v-for="dep in deps">
Expand Down
28 changes: 28 additions & 0 deletions public/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"bootswatch": "^5.3.1",
"chart.js": "^4.0.1",
"codemirror": "^5.65.15",
"dompurify": "^3.1.6",
"marked": "^14.0.0",
"vue": "^3.2.33",
"vue-router": "^4.0.14"
},
Expand Down

0 comments on commit 4e77b01

Please sign in to comment.