~jadedctrl/jam-xwx-moe

Showing details for patch c6fe5cf9cc57acd19924cb061945254cf1ae4d3a.
2023-08-12 (Sat), 9:43 PM - Jaidyn Ann - c6fe5cf9cc57acd19924cb061945254cf1ae4d3a

Kreas flikaĵon Pleroma-FE-an por »subpaĝoj«

Ĉi tiuj du flikaĵoj ebligas la tralegado de iuj
HTML-paĝoj nedinamikaj ene de Pleroma mem;
simple metu la paĝojn sub /static/paĝoj/.
Mi pensas, ke estas iom mojosa, plejparte senutila
kapablo! Sed kiel Tirifto jam diris, ni ja
strebas al mojoseco! c:
Summary of changes
2 files added
  • pleroma-fe/0001-Subtenon-de-subpa-oj.patch
  • pleroma-fe/0002-Ebligi-ligilojn-de-reguloj-pripanelo-al-subpa-oj.patch
diff -rN -u old-jam-xwx-moe/pleroma-fe/0001-Subtenon-de-subpa-oj.patch new-jam-xwx-moe/pleroma-fe/0001-Subtenon-de-subpa-oj.patch
--- old-jam-xwx-moe/pleroma-fe/0001-Subtenon-de-subpa-oj.patch	1970-01-01 00:00:00.000000000 +0000
+++ new-jam-xwx-moe/pleroma-fe/0001-Subtenon-de-subpa-oj.patch	2025-04-07 11:58:40.858776651 +0000
@@ -0,0 +1,240 @@
+From 63f5257c0e92433a7aee379cda51cdcae1e7352d Mon Sep 17 00:00:00 2001
+From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com>
+Date: Sat, 12 Aug 2023 12:36:26 -0500
+Subject: [PATCH 1/2] =?UTF-8?q?Subtenon=20de=20subpa=C4=9Doj?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+»Subpaĝo« estas neŝanĝanta HTML-dosiero, kiu
+povas montriĝi kiel kartopaĝo en Pleroma
+ĉe /paĝoj/$io.
+Simple kreu HTML-ajn dosierojn ĉe /static/static/*!
+---
+ src/boot/routes.js                            |  3 +
+ .../links_dynamically/links_dynamically.js    | 41 +++++++++++++
+ .../links_dynamically/links_dynamically.vue   | 11 ++++
+ src/components/subpage/subpage.js             | 56 +++++++++++++++++
+ src/components/subpage/subpage.vue            | 60 +++++++++++++++++++
+ 5 files changed, 171 insertions(+)
+ create mode 100644 src/components/links_dynamically/links_dynamically.js
+ create mode 100644 src/components/links_dynamically/links_dynamically.vue
+ create mode 100644 src/components/subpage/subpage.js
+ create mode 100644 src/components/subpage/subpage.vue
+
+diff --git a/src/boot/routes.js b/src/boot/routes.js
+index 2dc900e7..b67ad9e7 100644
+--- a/src/boot/routes.js
++++ b/src/boot/routes.js
+@@ -9,6 +9,7 @@ import DMs from 'components/dm_timeline/dm_timeline.vue'
+ import ChatList from 'components/chat_list/chat_list.vue'
+ import Chat from 'components/chat/chat.vue'
+ import UserProfile from 'components/user_profile/user_profile.vue'
++import SubPage from 'components/subpage/subpage.vue'
+ import Search from 'components/search/search.vue'
+ import Registration from 'components/registration/registration.vue'
+ import PasswordReset from 'components/password_reset/password_reset.vue'
+@@ -79,6 +80,8 @@ export default (store) => {
+     { name: 'about', path: '/about', component: About },
+     { name: 'announcements', path: '/announcements', component: AnnouncementsPage },
+     { name: 'user-profile', path: '/users/:name', component: UserProfile },
++    { name: 'subpage-index', path: '/pa%C4%9Doj', component: SubPage },
++    { name: 'subpage', path: '/pa%C4%9Doj/:page', component: SubPage },
+     { name: 'legacy-user-profile', path: '/:name', component: UserProfile },
+     { name: 'lists', path: '/lists', component: Lists },
+     { name: 'lists-timeline', path: '/lists/:id', component: ListsTimeline },
+diff --git a/src/components/links_dynamically/links_dynamically.js b/src/components/links_dynamically/links_dynamically.js
+new file mode 100644
+index 00000000..9a36f6f6
+--- /dev/null
++++ b/src/components/links_dynamically/links_dynamically.js
+@@ -0,0 +1,41 @@
++const LinksDynamically = {
++  props: [
++    'content'
++  ],
++  // Make sure that any internal links are handled by the router (most notably for intra-subpage links).
++  // Borrowed from a very lovely man by the name of Dennis Reimann:
++  // https://web.archive.org/web/20230607095633/https://dennisreimann.de/articles/delegating-html-links-to-vue-router.html
++  mounted () {
++    window.addEventListener('click', event => {
++      // ensure we use the link, in case the click has been received by a subelement
++      let { target } = event
++      while (target && target.tagName !== 'A') target = target.parentNode
++      // handle only links that do not reference external resources
++      if (target && target.matches("a:not([href*='://'])") && target.href) {
++        // some sanity checks taken from vue-router:
++        // https://github.com/vuejs/vue-router/blob/dev/src/components/link.js#L106
++        const { altKey, ctrlKey, metaKey, shiftKey, button, defaultPrevented } = event
++        // don't handle with control keys
++        if (metaKey || altKey || ctrlKey || shiftKey) return
++        // don't handle when preventDefault called
++        if (defaultPrevented) return
++        // don't handle right clicks
++        if (button !== undefined && button !== 0) return
++        // don't handle if `target="_blank"`
++        if (target && target.getAttribute) {
++          const linkTarget = target.getAttribute('target')
++          if (/\b_blank\b/i.test(linkTarget)) return
++        }
++        // don't handle same page links/anchors
++        const url = new URL(target.href)
++        const to = url.pathname
++        if (window.location.pathname !== to && event.preventDefault) {
++          event.preventDefault()
++          this.$router.push(to)
++        }
++      }
++    })
++  }
++}
++
++export default LinksDynamically
+diff --git a/src/components/links_dynamically/links_dynamically.vue b/src/components/links_dynamically/links_dynamically.vue
+new file mode 100644
+index 00000000..efcf7f94
+--- /dev/null
++++ b/src/components/links_dynamically/links_dynamically.vue
+@@ -0,0 +1,11 @@
++<template>
++  <!-- eslint-disable vue/no-v-html -->
++  <div
++    class="dynamic-content"
++    @click="handleClicks"
++    v-html="content"
++  />
++  <!-- eslint-enable vue/no-v-html -->
++</template>
++
++<script src="./links_dynamically.js"></script>
+diff --git a/src/components/subpage/subpage.js b/src/components/subpage/subpage.js
+new file mode 100644
+index 00000000..e4da7d9f
+--- /dev/null
++++ b/src/components/subpage/subpage.js
+@@ -0,0 +1,56 @@
++import LinksDynamically from '../links_dynamically/links_dynamically.vue'
++
++// Wow, I really don’t know how to write JS! Nor use Vue!
++// Hopefully this goes OK! ^^
++const SubPage = {
++  components: {
++    LinksDynamically
++  },
++  data () {
++    return {
++      content: 'Serĉante paĝon…',
++      title: 'Paĝo',
++      page: '',
++      error: false
++    }
++  },
++  methods: {
++    async switchPage (page) {
++      // Reset status…
++      this.title = 'Paĝo'
++      this.content = 'Serĉante paĝon…'
++      this.page = page || 'index'
++
++      // Fetch & parse the page’s content.
++      const response = await fetch('/static/paĝoj/' + this.page + '.html')
++      const htmlStr = await response.text()
++      const htmlDom = new DOMParser().parseFromString(htmlStr, 'text/html')
++
++      // Set the panel name & remove its corresponding header from HTML.
++      const firstChild = htmlDom.body.firstElementChild
++      if (/^[Hh][0-9]/.test(firstChild.tagName)) {
++        this.title = firstChild.innerHTML
++        firstChild.remove()
++      }
++
++      // Actually set the panel’s content.
++      this.content = htmlDom.body.innerHTML
++
++      if (!response.ok) {
++        this.error = true
++      }
++    }
++  },
++  created () {
++    this.switchPage(this.$route.params.page)
++  },
++  watch: {
++    '$route.params.page': function (newPage) {
++      if (newPage) {
++        this.switchPage(newPage)
++      }
++    }
++  }
++}
++
++export default SubPage
+diff --git a/src/components/subpage/subpage.vue b/src/components/subpage/subpage.vue
+new file mode 100644
+index 00000000..b56241ca
+--- /dev/null
++++ b/src/components/subpage/subpage.vue
+@@ -0,0 +1,60 @@
++<template>
++  <div>
++    <div class="panel panel-default">
++      <div class="panel-heading timeline-heading base02-background">
++        <div
++          v-if="error"
++          class="title"
++        >
++          Eraro 404 — Paĝo ne ekzistas!
++        </div>
++        <div
++          v-else
++          class="title"
++        >
++          {{ title }}
++        </div>
++      </div>
++      <div
++        v-if="error"
++        class="panel-body"
++      >
++        <div class="page-content">
++          <h4>La paĝo »{{ page }}« ne ekzistas!</h4>
++          <p>Ĉu vi certas, ke ne mistajpis la retadreson?</p>
++          <p>Krome, eblas ke foriĝis (aŭ neniam fariĝis) tiu paĝo. Tiuokaze, bedaŭron!</p>
++          <p>
++            Vi eble volas reviziti la
++            <router-link to="index">
++              paĝoliston
++            </router-link>.
++          </p>
++        </div>
++        <img
++          class="error-image"
++          src="/x_x/404.png"
++        >
++      </div>
++      <div
++        v-else
++        class="panel-body"
++      >
++        <div class="page-content">
++          <LinksDynamically :content="content" />
++        </div>
++      </div>
++    </div>
++  </div>
++</template>
++
++<script src="./subpage.js"></script>
++
++<style lang="scss">
++.page-content {
++  margin: 1em;
++}
++.error-image {
++  display: table-cell;
++  vertical-align: bottom;
++}
++</style>
+-- 
+2.40.1
+
diff -rN -u old-jam-xwx-moe/pleroma-fe/0002-Ebligi-ligilojn-de-reguloj-pripanelo-al-subpa-oj.patch new-jam-xwx-moe/pleroma-fe/0002-Ebligi-ligilojn-de-reguloj-pripanelo-al-subpa-oj.patch
--- old-jam-xwx-moe/pleroma-fe/0002-Ebligi-ligilojn-de-reguloj-pripanelo-al-subpa-oj.patch	1970-01-01 00:00:00.000000000 +0000
+++ new-jam-xwx-moe/pleroma-fe/0002-Ebligi-ligilojn-de-reguloj-pripanelo-al-subpa-oj.patch	2025-04-07 11:58:40.858776651 +0000
@@ -0,0 +1,83 @@
+From 4521a041efc54235c4bcf15494c26629c299bec5 Mon Sep 17 00:00:00 2001
+From: Jaidyn Ann <jadedctrl@teknik.io>
+Date: Sat, 12 Aug 2023 16:24:05 -0500
+Subject: [PATCH 2/2] =?UTF-8?q?Ebligi=20ligilojn=20de=20reguloj/pripanelo?=
+ =?UTF-8?q?=20al=20subpa=C4=9Doj?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Ĉi tio helpas la trovadon kaj reklamadon de paĝoj!
+---
+ .../instance_specific_panel/instance_specific_panel.js   | 5 +++++
+ .../instance_specific_panel/instance_specific_panel.vue  | 4 +---
+ .../terms_of_service_panel/terms_of_service_panel.js     | 5 +++++
+ .../terms_of_service_panel/terms_of_service_panel.vue    | 9 +++------
+ 4 files changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/src/components/instance_specific_panel/instance_specific_panel.js b/src/components/instance_specific_panel/instance_specific_panel.js
+index 09e3d055..3c0b9670 100644
+--- a/src/components/instance_specific_panel/instance_specific_panel.js
++++ b/src/components/instance_specific_panel/instance_specific_panel.js
+@@ -1,4 +1,9 @@
++import LinksDynamically from '../links_dynamically/links_dynamically.vue'
++
+ const InstanceSpecificPanel = {
++  components: {
++    LinksDynamically
++  },
+   computed: {
+     instanceSpecificPanelContent () {
+       return this.$store.state.instance.instanceSpecificPanelContent
+diff --git a/src/components/instance_specific_panel/instance_specific_panel.vue b/src/components/instance_specific_panel/instance_specific_panel.vue
+index c8ed0a2d..a49c20cf 100644
+--- a/src/components/instance_specific_panel/instance_specific_panel.vue
++++ b/src/components/instance_specific_panel/instance_specific_panel.vue
+@@ -2,9 +2,7 @@
+   <div class="instance-specific-panel">
+     <div class="panel panel-default">
+       <div class="panel-body">
+-        <!-- eslint-disable vue/no-v-html -->
+-        <div v-html="instanceSpecificPanelContent" />
+-        <!-- eslint-enable vue/no-v-html -->
++        <LinksDynamically content="instanceSpecificPanelContent" />
+       </div>
+     </div>
+   </div>
+diff --git a/src/components/terms_of_service_panel/terms_of_service_panel.js b/src/components/terms_of_service_panel/terms_of_service_panel.js
+index 4276f8f7..41382c60 100644
+--- a/src/components/terms_of_service_panel/terms_of_service_panel.js
++++ b/src/components/terms_of_service_panel/terms_of_service_panel.js
+@@ -1,4 +1,9 @@
++import LinksDynamically from '../links_dynamically/links_dynamically.vue'
++
+ const TermsOfServicePanel = {
++  components: {
++    LinksDynamically
++  },
+   computed: {
+     content () {
+       return this.$store.state.instance.tos
+diff --git a/src/components/terms_of_service_panel/terms_of_service_panel.vue b/src/components/terms_of_service_panel/terms_of_service_panel.vue
+index bff0ae74..0d90c00d 100644
+--- a/src/components/terms_of_service_panel/terms_of_service_panel.vue
++++ b/src/components/terms_of_service_panel/terms_of_service_panel.vue
+@@ -2,12 +2,9 @@
+   <div>
+     <div class="panel panel-default">
+       <div class="panel-body">
+-        <!-- eslint-disable vue/no-v-html -->
+-        <div
+-          class="tos-content"
+-          v-html="content"
+-        />
+-      <!-- eslint-enable vue/no-v-html -->
++        <div class="tos-content">
++          <LinksDynamically :content="content" />
++        </div>
+       </div>
+     </div>
+   </div>
+-- 
+2.40.1
+