لقد قمت بتضمين نظام Discourse في موقعي (Embed Discourse comments on another website via Javascript - #309 by eviltrout). يقوم Discourse بإنشاء منشورات تحتوي على معاينة لموقعي. كيف يمكنني إعادة إنشاء أو إعادة جلب منشور مضمن من هذا النوع، حيث قمت بتغيير معلمات الزحف وأود إعادة جلب معاينة الصفحة التي تم تضمين Discourse فيها؟
هل سيساعد إعادة الخبز؟ هل هناك أمر في وحدة التحكم؟
وجدت أن
TopicEmbed.find_remote(url)
يبدو مفيدًا لعرض ما سيتم جلبه.
Looking through the source I found this to be a working solution:
username = SiteSetting.embed_by_username.downcase
user = User.where(username_lower: username.downcase).first
embed_url = "http://www.example.org" # or use the url from topic as shown below
TopicEmbed.import_remote(user, embed_url)
taken from TopicRetriever.fetch_http (discourse/lib/topic_retriever.rb at 888e68a1637ca784a7bf51a6bbb524dcf7413b13 · discourse/discourse · GitHub)
where embed_url is the url of the site where discourse is embedded, coming from the topic with the number topic_id this may be
embed_url = TopicEmbed.where(topic: topic_id)[0].embed_url
This seems a bit complicated to just refetch. Is it correct anyway? Is there a simpler possibility?