diff --git a/docute-wikilink.js b/docute-wikilink.js new file mode 100644 index 0000000..f9a11e8 --- /dev/null +++ b/docute-wikilink.js @@ -0,0 +1,20 @@ +const re = /\[\[([\w\s]+)\]\]/g; // [[SupaHam]] +const rePiped = /\[\[([\w\s]+)(?:\|)(\w+)\]\]/g; // [[Pineapple|MD678685]] + +const replacement = `$text`; + +function docuteWikilink(context) { + context.beforeParse(content => { + /* + const parsed = content.replace(re, `[$1]($1)`) + .replace(rePiped, "[$1]($2)"); + */ + const parsed = content.replace(re, (match, p1) => + replacement.replace("$text", p1).replace("$uri", p1.replace(" ", "-"))) + .replace(rePiped, (match, p1, p2) => + replacement.replace("$text", p1).replace("$uri", p2)); + + console.log(content, parsed); + return parsed; + }); +}; diff --git a/index.html b/index.html index a886e67..c6a61d0 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,8 @@ + + diff --git a/main.js b/main.js index 00c6cc4..ad7d20e 100644 --- a/main.js +++ b/main.js @@ -3,78 +3,7 @@ const mirrorCI = "https://ci.akpmakes.tech/job/EssentialsX/"; axios.defaults.baseURL = mirrorCI; // ender.zone doesn't allow CORS -const landing = { - html: ` - -
-

-

This is not an official EssentialsX site.

-

Download EssentialsX

-
-

The latest version of EssentialsX is {{build}}.

-

Could not retrieve information about the latest version.

- - - - - - - - - - - -
PluginMainMirror
{{ plugin.name }}DownloadDownload
- -
-

Help for EssentialsX

-
- Go to EssentialsX Wiki -
-
-
- `, - component: { - data() { - return { - buildNo: null, - failed: null, - plugins: [], - }; - }, - computed: { - build() { - return this.buildNo ? `b${this.buildNo}` : "unknown"; - }, - }, - methods: { - updateInfo() { - axios.get("lastSuccessfulBuild/api/json") - .then(response => { - this.buildNo = response.data.id; - this.plugins = response.data.artifacts.map(artifact => { - return { - name: `EssentialsX ${artifact.displayPath.match(/EssentialsX([A-Za-z]*)/)[1]}`, - main: `${mainCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`, - mirror: `${mirrorCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`, - }; - }); - this.failed = null; - }, error => { - if (error.response) { - this.failed = error.response.data; - } else { - this.failed = error.message; - } - } - ); - } - }, - mounted: function () { - this.updateInfo(); - } - }, -} +const landing = window.dlPage; docute.init({ url: "https://raw.githubusercontent.com/wiki/EssentialsX/Essentials/", @@ -103,5 +32,8 @@ docute.init({ { title: "Issue Tracker", path: "https://github.com/EssentialsX/Essentials/issues" }, { title: "Discord", path: "/Discord-Rules" } ], + plugins: [ + docuteWikilink, + ], debug: true }); \ No newline at end of file diff --git a/vue-dlpage.js b/vue-dlpage.js new file mode 100644 index 0000000..85da387 --- /dev/null +++ b/vue-dlpage.js @@ -0,0 +1,74 @@ +const component = { + html: ` + +
+

+

This is not an official EssentialsX site.

+

Download EssentialsX

+
+

The latest version of EssentialsX is {{build}}.

+

Could not retrieve information about the latest version.

+ + + + + + + + + + + +
PluginMainMirror
{{ plugin.name }}DownloadDownload
+ +
+

Help for EssentialsX

+
+ Go to EssentialsX Wiki +
+
+
+ `, + component: { + data() { + return { + buildNo: null, + failed: null, + plugins: [], + }; + }, + computed: { + build() { + return this.buildNo ? `b${this.buildNo}` : "unknown"; + }, + }, + methods: { + updateInfo() { + axios.get("lastSuccessfulBuild/api/json") + .then(response => { + this.buildNo = response.data.id; + this.plugins = response.data.artifacts.map(artifact => { + return { + name: `EssentialsX ${artifact.displayPath.match(/EssentialsX([A-Za-z]*)/)[1]}`, + main: `${mainCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`, + mirror: `${mirrorCI}lastSuccessfulBuild/artifact/${artifact.relativePath}`, + }; + }); + this.failed = null; + }, error => { + if (error.response) { + this.failed = error.response.data; + } else { + this.failed = error.message; + } + } + ); + } + }, + mounted: function () { + this.updateInfo(); + } + }, +}; + +window.dlPage = component; \ No newline at end of file