Proposed Plugin Overview:
Plugin Outlet: topic-category
Discourse plugin to add a integer value
from the topic_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 from the topic_custom_fields
table from the matching topic_id
for the name
import_id
value. Example query:
discourse=> select * from topic_custom_fields where name like '%import%' order by id desc limit 1;
id | topic_id | name | value | created_at | updated_at
--------+----------+-----------+---------------+----------------------------+----------------------------
239741 | 378256 | import_id | thread-284207 | 2020-05-03 09:02:39.150186 | 2020-05-03 09:02:39.150186
(1 row)
The required value is the integer from the value thread-284207
above.
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.