Bug Report For Dpoll ― Improving How Polls Are Shown

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@tdre·
0.000 HBD
Bug Report For Dpoll ― Improving How Polls Are Shown
This post discusses two bugs I encountered recently on one of my favorite Steem front ends. The dpoll site (http://dpoll.xyz), as many users know, lets you pose questions to fellow Steemians and record the answers on the Steem blockchain. It's a continually improving open source dcentralized app for fun or serious surveys.  

![dpoll](https://steemitimages.com/0x0/https://steemitimages.com/600x800/https://steemitimages.com/p/4i88GgaV8qiFU89taP2MgKXzwntUGAvkoQiKU7VxyD37q94Wi9c7sckcogtYxZUCMZDdF5zmwoKUZWw1iZw1YDMLq33p3D4GSpz3CzvSn3BMn9D8qospTKaVPt?format=match&mode=fit&width=640)

#### Project Information
* Repository: https://github.com/emre/dpoll.xyz
* Project Name: dpoll
* Publisher (if applicable): @emrebeyler

### Escaped Character Code Rendered Between Markdown Backticks

The first of these two bugs involves the way Markdown is rendered.

#### Expected Behavior

An HTML character entitity between single backticks in markdown should render as the corresponding human legible symbol. 

For example, `'` in `That's not funny` should be rendered as an apostrophe.

To show further, [this dPoll](https://busy.org/@tdre/lets-try-another-meme-is-this-one-amusing) is rendered correctly on Busy.org.

![image](https://user-images.githubusercontent.com/868675/53489247-b7699e80-3a5e-11e9-9b5c-01c1a3c46f61.png)

#### Actual Behavior

On dPoll.xyz the character entitity code is shown in the rendered Markdown.

The following image shows [the same poll](https://dpoll.xyz/detail/@tdre/lets-try-another-meme-is-this-one-amusing/) as rendered by the dPoll website.

![image](https://user-images.githubusercontent.com/868675/53489328-e7b13d00-3a5e-11e9-8cab-402d9fdefc57.png)

#### Steps To Reproduce

1. Create a new poll.
2. Add Question.
3. Add a Description, including an inline snippet enclosed by back ticks (`` ` ``). There should be at least one HTML character that calls for entity encoding within the snippet.  For example:
```
Lorem ipsum dolor sit amet. `This snippet's apostrophe shows the problem.`
```
4. Add answers.
5. Submit the poll.

#### Analysis And Suggested Solution

I suspect this behavior is tied to [Line #39](https://github.com/emre/dpoll.xyz/blob/master/dpoll/templates/poll_detail.html#L39) in dpoll's `poll_detail.html` template.

```html
<p>
    {{ poll.description |striptags | force_escape | markdown |safe }}
</p>
```
Combining Django's [built-in template tags](https://docs.djangoproject.com/en/2.1/ref/templates/builtins/) this way could be tricky, particularly in regards to `force_escape`, which causes an HTML string to be escaped multiple times over.  I am not sure what exact filter combination, if any, would eliminate the entity codes.  But it's an option to consider.

### Edits Made in Other Front Ends Don't Display On dPoll

This second bug I actually discovered while closely examing the example posts in the foregoing issue.  It turns out that editing the post body on a different Steem front end (e.g. Busy.org) is not doing what many users would expect.

This may or may not be by design.  But I think it bears examination because it could be confusing.

#### Expected Behavior

When a user edits a post the most recent version is displayed on front ends that serve a general audience.

#### Actual Behavior

When a user edits a poll using a Steem blockchain frontend other than dPoll the changes are not visible on the website https://dPoll.xyz.

For example, compare this post on [dPoll](https://dpoll.xyz/detail/@tdre/lets-try-another-meme-is-this-one-amusing/) and [Busy.org](https://busy.org/@tdre/lets-try-another-meme-is-this-one-amusing). 

__The post has been edited using Busy.org to correct a typo in the first paragraph.__
__I.e. `@rem-steem` replaces `rem-stem`.__

![poll-on-busy-org](https://user-images.githubusercontent.com/868675/53523261-5f588980-3aaa-11e9-8947-3f741ecf2937.png)

__But the change does not show up on dPoll.__

![image](https://user-images.githubusercontent.com/868675/53523554-21a83080-3aab-11e9-89a5-92ec3865067f.png)

#### Steps To Reproduce

1. Create a poll on dPoll.xyz.
2. Edit the poll using Busy.org or Steemit.com

#### Analysis And Suggested Solution

I belive the disparity arises because dPoll is reading what it displays from `json_metadata.question` and `json_metadata.description` and thus cannnot pickup on changes that were made elsewhere.

This can be seen in the [steemd.com](https://steemd.com/dpoll/@tdre/lets-try-another-meme-is-this-one-amusing) view. 

![steemd-of-post-example](https://user-images.githubusercontent.com/868675/53524411-50270b00-3aad-11e9-8500-ee00169ef1ca.png)

While these are technically different properties from the post body and there is nothng wrong per se with writing custom `json_metadata` for dPoll's particular purpose, I expect the typical, non-technical user will find this confusing.

One way this might be addressed is by comparing post's `created`property to its `last_edited` property and in cases where the two differ render the post's current blog body and title instead of  `json_metadata.question` and `json_metadata.description`.

Report(s) To The Maintainer

- @tdre opened thes as issues [#97](https://github.com/emre/dpoll.xyz/issues/97) and [#98](https://github.com/emre/dpoll.xyz/issues/98) in the dpoll repository [here](https://github.com/emre/dpoll.xyz/issues).
- The problem was mentioned to the developers' #bug-reports channel on discord.

![image.png](https://ipfs.busy.org/ipfs/QmV2BD9NtFRhY5qCi8mYoWVRunGsdv4kGV4k5XWxsxdUJ1)


---

#### GitHub Account
https://github.com/tdreid
![@tdre on the Steem blockchain](https://steemitimages.com/0x0/https://ipfs.busy.org/ipfs/QmRebopnSyfF6NyUPCdFDWRFVdAzCnfy6dnfg24NVK9BvJ)
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,