أنا أستخدم طلب API الخاص بـ Discourse لإنشاء فئة، ولكن في نفس العملية أود إضافة نص أو مرجع URL وما إلى ذلك إلى وصف الفئة (أو هل هو description_text كما أحاول فهم الخصائص أو الاختلافات).
لاحظ أيضًا أنه قد يكون هناك “روبوت” يضيف إلى هذا، لذا فإن أفضل طريقة…
إنشاء فئة (يعمل)
تحديث الفئة أو بالأحرى إرفاق الرابط، ولكن إلى category.description أم category.description_text؟
ومع ذلك، لا توجد خصائص للتحديث سوى name، color، text_color، لذا هل هناك خصائص أخرى يمكنني إرسالها؟ مثل (وأي) description أو/وربما description_text؟
كل ما أريده هو إضافة رابط slug إلى موقع مرتبط بالفئة التي أنشئها… أو ببساطة إضافة في نهاية وصف فئة Discourse “[link][https/example.projectxxx”.
Although the docs only list those 3 properties, most of the properties mentioned in the Response object can be set on the create call. I found this out when I needed to script the creation of a large number of categories with the same settings except for the name and slugs.
The only property I needed to set and consistently had issues with is the permissions.
Yes, I’ve noticed that properties allowed are not those defined in the API documentation.
However to set the Category “description” which is very confusing as the category description is not at all what is displayed, in fact below the category name is the HTML element “cooked” which is empty, so how to set that…
From what I’ve been able to understand, I must set a post in the “About the --category name-- …” and it must be the first post in that category, but I think there is other critaria, like the cooked or also the fact that we have a Bot that first posts there.
I’ve tried adjusting the created_at/updated_at dates to make my post appear above so that the category will grab or use that description, but no luck! There must be something I’m not understanding about the “cooked” and/or category description. Very confusing and I’ve found no docs, but I’ll keep looking, if anyone has ideas on what to try, please let me know.
مرحباً، أقوم بإحياء هذا الموضوع القديم..
هل هناك أي طريقة لفهم الفرق بين description_text و description؟
أعني بخلاف اكتشاف ذلك عن طريق التجربة
ربما اكتشف @alank ذلك الآن!
شكراً!
إذا لم يتم توثيقه في مكان آخر، فإن البحث داخل ملفات المواصفات في مستودع discourse سيجيب على أشياء كهذه بفهم أساسي لكيفية عمل لغات البرمجة.
في هذه الحالة، توضح الأسطر التالية في مواصفات الفئة أن description_text مشتق من description ومتاح فورًا بعد تعيين description.
هذا يعني بالنسبة لي أن description هو السلسلة النصية الخام للوصف وعند تعيينها، يتم معالجتها وتعيينها إلى description_text. أو يمكن حساب description_text عند الوصول إليها ولكنني أشك في ذلك، وفي كلتا الحالتين description هو الذي يجب تعيينه.
إذا لم يتم توثيقها لحمولة طلب POST، فلا يمكنك الاعتماد على القدرة على تعيينها بهذه الطريقة حتى لو نجحت.
أعتقد أن الشيء الذي يجب القيام به هو النظر إلى topic_url في الاستجابة بعد إنشاء الفئة، ثم الحصول على موضوع واحد باستخدام المعرف من هذا الرابط. انظر إلى post_stream في الاستجابة التي تحتوي على مصفوفة من المشاركات، وأتخيل أن هذا سيكون له عنصر واحد.
احصل على معرف هذه المشاركة ثم قم بتحديث مشاركة واحدة لإضافة وصفك. يجب أن يؤدي ذلك إلى تحديث وصف الفئة بنفس الطريقة التي يتم بها تحرير المشاركة في Discourse، مع نفس قاعدة السطر الأول.