Superseded by this requirement (v2):
Not Parsed Code Block
Proposed Plugin Overview:
Plugin Outlet: topic-category
Discourse plugin to add a integer value
from the post_custom_fields
postgres table and insert that value as follows into the appropriate topic JSON API serializer so it will be available in the Get a single topic
API here:
https://docs.discourse.org/#tag/Topics/paths/~1t~1{id}.json/get
The serialized additional JSON entry to the API should be in this format:
"legacy_threadid": <integer>
(location after the id (of the topic) preferred but not required:
Where the integer is the (first) value from this (or similar query):
Draft Query:
discourse=> select c.value as legacy_threadid ,p.topic_id from post_custom_fields c join posts p on (p.id = c.post_id) where c.value like '%thread%' and p.topic_id =376851;
legacy_threadid | topic_id
-----------------+----------
thread-283354 | 376851
(1 row)
In this real-world example, split the resulting thread-283354
and return only the integer 283354
in the API as:
"legacy_threadid": 283354
If there is no match, return 0;
Configurable so only users with specified trust level or above in setting can access (only runs for this trust level and above)
Finally, add any required code to make this value available to a Discourse theme component (based on emberjs) as a property, such as:
{{legacy_threadid}}
and also add an option (via the plugin settings) to display a <span>
at plugin-outlet:
connectors/topic-category
Where the template is defined in the plugin setttings.yml
plugins:
legacy_forum_info_enabled:
default: false
client: true
plugin_outlet_enabled:
default: true
template: 'handlebars template'. #see below
minimum_trust_level: trust_level_4 #configurable
Example Template:
<span class="legacy-threadid">Legacy thread <a class="legacy-threadid-link" href="https://www.unix.com/showthread.php?t={{legacy_threadid}}</a></span>
- Required Delivery Date: No big rush, hopefully within a few weeks.
- Budget: Open to reasonable offers for this small plugin.
- Prefer Javascript plugin (if possible) but can discuss Ruby
Any questions, please ask. Thanks.
Notes
-
The purpose of this plugin is primarily so the staff can check the post text (integrity check) in the original forum if they see any "oddities" in the migrated posts, especially in
code
orbbcode
translations. This plugin is not intended for anyone other than our staff to use. -
If the DB query returns no match the template should display a configurable template from the settings.
-
Development questions and collaboration on this plugin should occur openly in this topic.