New StemQ Features: Link to question page and default tags

in #utopian-io6 years ago (edited)

Repository

https://github.com/irelandscape/quearn

Pull Request

https://github.com/irelandscape/quearn/pull/20

New Features

Many people are still reading StemQ posts using other Steem apps such as Steempeak or Steemstem.io.

One point that has been raised on several occasions is that, when reading an answer post, it would be nice to have a link to the original question post.
The StemQ UI facilitates this by presenting a button redirecting the user the original question page.
However other Steem applications are not aware of the relationship between questions and answers and therefore do not offer this facility.
The first feature added by this PR is the insertion of a link to the original question in the answer post.

The second feature that has been added with this PR is the capability for the administrator to configure a list of default tags to be suggested to the user when submitting a new post.
Some people have been confused on whether or not they should specify the #steemstem tag on their StemQ posts and this feature is now used to automatically suggest the #steemstem tag. This tag can be removed by the user if so desired.

StemQ automatic insertion of link to question within answer post

Screenshot-from-2019-01-08-15-35-27.png

A new feature has been added to StemQ whereby any answer submitted on stemq.io will have a text notice inserted at the beginning of the post along with a link to the question post.

The notice and the link, while visible on other Steem apps, is automatically removed from the post body when viewing the answer using the StemQ UI.

The code changes extend on the existing feature whereby another StemQ notice is already added at the end of all posts to let people know that an article has been posted through stemq.io

How was this feature implemented?

Quearn now maintains an array of regular expressions to look for in post bodies. Any string matching these regular expressions is automatically removed from the main text before being rendered on the screen.

A single regular expression is currently inserted into this array when the application start.
This is shown in the code snippet below (this code belongs to the Quearn Quasar plugin code which is invoked at startup):

 axios.get(store.getters['quearn/serverURL'] + '/configs/').then(
    function (response) {
      let config = response.data[0]
      store.commit('quearn/config', config)
      // document.title = config.appName

      store.commit('quearn/removePatterns', new RegExp('\\*\\*' + config.appName + ' [Nn]otice:.*\n*', 'g'))
    }).catch(
    function (error) {
      console.log(error)
      Notify.create('Failed to contact API Server')
    })

So, as can be seen from the above, the regular expression will match any line matching "**<application name> [Nn]otice:" following by empty lines.

For StemQ, this means that all lines matching "StemQ [Nn]otice:" will be removed.

The link to the question is evaluated by the following code:
Screenshot-from-2019-01-08-15-16-02.png

The code above does two things.
It prepends a StemQ notice at the start of the body, using the i18n translation of the "linktoquestion" text.
It evaluates the URL to the question and substitute the @LINK string with this URL in the notice.

Finally, the code generating HTML from markdown had to be updated to remove all text matching the regular expressions previously mentioned:
Screenshot-from-2019-01-08-15-23-29.png

Default tags

Screenshot-from-2019-01-06-19-32-30.png

This feature the administrator to configure a comma separated list of tags which will be automatically offered to the user upon submitting a new post on StemQ.

StemQ uses this feature to offer the #steemstem tag. The user is free to remove this default tag.

How was this feature implemented?
First, a "default_tags" was added to the quearn-server backend Django application.

The ediblog.js script which manages the post submission form has been updated to split this comma separated list and present the corresponding tags in the QChipsInput form field:
Screenshot-from-2019-01-08-15-28-35.png

GitHub Account

https://github.com/irelandscape

Sort:  

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 62102.06
ETH 2415.08
USDT 1.00
SBD 2.49