Git Product home page Git Product logo

Comments (5)

docapotamus avatar docapotamus commented on June 15, 2024

Posts are moving to a more pre-processing method. Links, mentions and hashtags will all be parsed at the time you post and stored along side the post. This will mean looking for them only happens once, it will also allow users the ability to de-tag themselves and such in the future.

This is going to take a little work to get all of these processed before hand but at least will only happen the once. The front end will then be able to process the stored data for highlighting which we hope will be quicker as what it needs to highlight will be stored. In the future we could even store a copy of this in the database but caching it is also a good idea. If the post is changed in any way these can then be updated.

The new models for posts I am thinking is such:

{
  "_id": "<UUID>",
  "reply_to": "<UUID>",
  "user_id": "<UUID>",
  "username": "username",
  "created": 1427189599,
  "score": 0,
  "body": "Hello world!",
  "upload": "<filename>",
  "comment_count": 1,
  "links": [{
    "url": "pjuu.com",
    "span": [1, 9]
  }],
  "mentions": [{
    "user_id": "<UUID>",
    "username": "username",
    "span": [1, 9]
  }],
  "hashtags": [{
    "tag": "hashtag",
    "span": [1, 8]
  }]
}

This would never happen because there is multiple fields which would not appear at the same time (post vs. reply). Documenting this as an idea.

from pjuu.

docapotamus avatar docapotamus commented on June 15, 2024

This is a harder problem that I first thought. The code in master is not much use as it can match a URL, mention or hashtag on the same string.

It going to have to work like Jinja2's urlize a bit more. Split the string on spaces then try and match each one to a regex. The first one it matches it will be treat as that.

This will require changing the regex's slightly but should work. I will push changes when I get it sorted.

from pjuu.

docapotamus avatar docapotamus commented on June 15, 2024

This also isn't going to work that well. Will probably take some pointer from Twitter and the twitter-text repository. I have already refactored out the parsers in to the lib package. Will push when I get chance.

from pjuu.

docapotamus avatar docapotamus commented on June 15, 2024

This feature is in but it needs some polish. It realistically should have been done as a PR but we now know for another time.

from pjuu.

docapotamus avatar docapotamus commented on June 15, 2024

Related to #64.

Going to close as this will be fixed with that issue as parsing out hashtags is all that is left.

from pjuu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.