ponder-lab / Imperative-DL-Study-Web-App

0 stars 0 forks source link

URLize URLs in text fields #85

Closed khatchad closed 3 years ago

khatchad commented 3 years ago

If a URL is found in a text field, please activate its link. This would make it easier to read the data. It should apply to all text fields in each view. Really, this is all of the "comment" fields. For example, in https://fathomless-inlet-57767.herokuapp.com/ponder/categorizations?user=11, I see the following value for "func fix comment" for categorization with ID 17:

<td>Referenced issue: https://github.com/tensorflow/probability/issues/542. Also, fails the build. Just looks like new code.</td>

Instead, it would look like this:

<td>Referenced issue: <a href="https://github.com/tensorflow/probability/issues/542">https://github.com/tensorflow/probability/issues/542</a>. Also, fails the build. Just looks like new code.</td>

I found a SO post about this but its quite dated.

khatchad commented 3 years ago

Another option would be to use a regex to find and replace each text field. I found this: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url.

ZhongweiL commented 3 years ago

I am stuck trying to figure out how to manipulate or modify the content in the td tag, any suggestions?

mZneit commented 3 years ago

Here's a link to help you with the attributes: https://django-tables2.readthedocs.io/en/latest/pages/column-attributes.html You need to modify the contents from the tables.py file, not the HTML file. There are some modifications of the td attributes in this file that I did before. You may need to use some of the code.

ZhongweiL commented 3 years ago

@mZneit Do you know any way we can change the rendered value of multiple columns? I know that the render_FOO function modifies the rendered data of a single column, but the issue requires the change to apply to every text field, is there any way for the render function to apply the same modification to multiple columns so that we don't have to repeat ourselves? Or do you have other suggestions? If not, then the best solution I can think of is to define a render_FOO function for every required column.

mZneit commented 3 years ago

There's a way to modify multiple columns at the same time. You have to work with the meta data of the table where you choose the columns that you want to modify. I'm not sure if this will work in this case though.