V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iugo
V2EX  ›  Project Babel

万能贴图修改,可以在PB2中随意贴图

  •  
  •   iugo · 2010-12-09 23:18:15 +08:00 · 4629 次点击
    这是一个创建于 4903 天前的主题,其中的信息可能已经有所发展或是发生改变。
    简单替换,实现各种功能,不过安全隐患未经证实。

    原帖: http://bbs.blueidea.com/thread-2728149-1-1.html
    我以前在 LeadBBS 中看到的。

    修改方法:

    在模板帖子展示处添加 <span id=clian.net> </span>

    然后在页尾添加如下代码:
    <script language="javascript">
    //<!--
    function code(id)
    {
    if (document.getElementById(id))
    {
    document.getElementById(id).innerHTML = convertcode(document.getElementById(id).innerHTML);
    }
    }
    function convertcode(str)
    {
    str = str.replace(/\[http\:\/\/(.+?)\.gif/gi,"<img src='http://$1.gif' />");//gif
    str = str.replace(/\[http\:\/\/(.+?)\.jpg/gi,"<img src='http://$1.jpg' />");//jpg
    str = str.replace(/\[http\:\/\/(.+?)\.png/gi,"<img src='http://$1.png' />");//png
    return str;
    }
    code('clian.net');
    //-->
    </script>
    7 条回复    1970-01-01 08:00:00 +08:00
    iugo
        1
    iugo  
    OP
       2010-12-09 23:19:11 +08:00
    贴图方法:在图片链接前加 [
    dimlau
        2
    dimlau  
       2010-12-10 01:02:25 +08:00
    你稍做修改之后放进 filters.py 得了。
    不过既然匹配前缀,就没必要匹配后缀名了吧,很多图片地址是不带后缀名的。
    iugo
        3
    iugo  
    OP
       2010-12-10 18:26:19 +08:00
    @dimlau 这个的好处是js,浏览器来处理。
    alai
        4
    alai  
       2010-12-14 16:43:06 +08:00
    有没有演示地址?
    dimlau
        5
    dimlau  
       2010-12-14 16:48:34 +08:00
    呃,这个更全面了。
    http://www.v2ex.com/t/5698
    alai
        6
    alai  
       2010-12-17 13:56:27 +08:00
    有人试过PB2+textile了吗?
    imsein
        7
    imsein  
       2010-12-23 01:37:43 +08:00 via iPod
    不错,mark
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   979 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 19:42 · PVG 03:42 · LAX 12:42 · JFK 15:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.