【问题标题】:Rendering of a quote of another discourse post渲染另一篇文章的引用
【发布时间】:2019-01-13 21:33:41
【问题描述】:

我创建了一个 WordpressComment 类来检查评论是否引用了另一个评论。如果是这样,它会以与 UI 相同的模式添加引用

def body(lookup)
  quoted = nil
  parent = nil
  if parent_import_id != nil then
    parent_id = lookup::post_id_from_imported_post_id(parent_import_id)
    parent = Post.where(id:parent_id).first
    if parent != nil then
      user = User.where(id:parent.user_id).first
      @parent_user_name = user.username_lower
      quoted = "[quoted=\"#{parent_user_name}, post:#{parent.post_number}, topic:#{parent.topic_id}\"]<br/><br/>#{parent.cooked}<br/>[/quote]<br/>"
    end
  end
  return "#{quoted}#{content}<p /><p />#{author}<p />#{author_url}".gsub(/\\n/,'<br/>').strip[0...32000]
end

它插入了正确的链接..但它没有正确呈现。

看起来像这样

[quote="{username}, post:{post_id}, topic:topic_id"] ...引用的文字... [/quote]

我研究了search?q=quoting another post #dev

有趣的是,我发现了一些具有相同引用问题的帖子。

如何在 post.raw 中添加另一篇文章的引用以使其被渲染?

【问题讨论】:

    标签: discourse


    【解决方案1】:

    向 meta.discousre.org 上的 Florian 致敬

    问题是我引用而不是引用,并且在引用块的末尾必须有一个换行符。

    修复错字并插入换行符有效!

    def body(lookup)
      quoted = nil
      parent = nil
      if parent_import_id != nil then
        parent_id = lookup::post_id_from_imported_post_id(parent_import_id)
        parent = Post.where(id:parent_id).first
        if parent != nil then
          user = User.where(id:parent.user_id).first
          @parent_user_name = user.username_lower
          quoted = "[quote=\"#{parent_user_name}, post:#{parent.post_number}, topic:#{parent.topic_id}\"]<br/><br/>#{parent.cooked}<br/>[/quote]\n<br/>"
        end
      end
      return "#{quoted}#{content}<p /><p />#{author}<p />#{author_url}".gsub(/\\n/,'<br/>').strip[0...32000]
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-24
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-27
      • 2019-11-14
      相关资源
      最近更新 更多