[DONE] Requirements for Discourse Plugin for Topic Serializer (API) v2

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

Screen Shot 2020-05-09 at 7.59.39 PM

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:

Screen Shot 2020-05-09 at 8.15.40 PM

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


  1. 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 or bbcode translations. This plugin is not intended for anyone other than our staff to use.

  2. If the DB query returns no match the template should display a configurable template from the settings.

  3. Development questions and collaboration on this plugin should occur openly in this topic.

Thanks to some coaching by @spirobel we have the TopicViewSerializer part of this task working now :slight_smile:

1 Like

Update:

The work on this plugin is progressing thanks to some gentle coaching, encouragement, and hand-holding by @spirobel.

Still working on the code, step-by-step, and will polish it up and make it available for other Discourse migrators who might have a similar requirement in the future.

@spirobel has been really great to work with, letting me do most of the work and debugging myself, but providing me tips, code, draft PRs, and clues when I hit a brick wall.

Thanks @spirobel !

1 Like

The core technical pieces of this plugin are basically done.

Tomorrow will clean up the code, test some more, push out to github and install it here.

Update:

Just completed (alpha version) and have started live testing my first plugin.

Status:

  • Live testing

TODO

  • This is my first Discourse plugin. The link to the legacy forum is hard coded into the component. Need to make this configurable setting.
  • Improved plugin over time to bring the coding up to "Discourse standard", because it is far from that now.
  • Post in the #plugin category when the testing is done.

Acknowledgement

A special thank you to @spirobel for coaching me yesterday and helping me get the serializer working and the basic component structure working.

Caveat

All "non-standard or bad coding" practices are all mine.

Notes

This legacy forum info is only visible (configurable) to trust level 4 members on our forums;

1 Like

Update:

Created new (and much faster) Discourse development environment on macOS today:

and with a much faster way to debug plugins, I fixed the settings issue with this plugin:

Now version 0.0.3:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.