V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
lzy4223
V2EX  ›  Python

mention 功能是如何實現的?

  •  
  •   lzy4223 · 2015-07-20 19:28:13 +08:00 · 2513 次点击
    这是一个创建于 3173 天前的主题,其中的信息可能已经有所发展或是发生改变。

    以v2ex的mention功能為例。

    我的想法是,提交輸入內容後,用正則尋找“@”字符,再取得“@”後面的文字字段,如果數據庫裏面有這個用戶,就給@字段添加用戶profile鏈接和發送notification。

    後端是python的django。

    這個思路對嗎?有不對請指正。

    還是應該在前端用javascript來實現?

    5 条回复    2015-07-21 17:52:58 +08:00
    clino
        1
    clino  
       2015-07-20 19:59:29 +08:00 via Android
    后端实现比较好吧
    lzdhlsc
        2
    lzdhlsc  
       2015-07-21 02:21:10 +08:00   ❤️ 1
    可以看v2ex的源代码,https://github.com/livid/v2ex/blob/master/v2ex/templatetags/filters.py - mentions function
    jasonz
        3
    jasonz  
       2015-07-21 11:00:30 +08:00   ❤️ 1
    前端实现可以看redmine插件https://github.com/arkhitech/redmine_mentions
    lzy4223
        5
    lzy4223  
    OP
       2015-07-21 17:52:58 +08:00
    @lzdhlsc
    這個貌似挺舊的了,是用模板的filter做的。
    但是有個問題是,我們現在被@了後,其實是會收到notification的。但用模板做,沒有實現這個功能。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5334 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:21 · PVG 17:21 · LAX 02:21 · JFK 05:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.