RiftWorks
Найти
Персональное меню
Вы не представились системе
user-interface-preferences
Персональные инструменты
Обсуждение
Вклад
Создать учётную запись
Войти
Параметры
notifications
Редактирование:
Guide to autowiki
(раздел)
associated-pages
Статья
Обсуждение
Просмотры
Читать
Править
Править код
История
Внимание:
Вы не вошли в систему. Ваш IP-адрес будет общедоступен, если вы запишете какие-либо изменения. Если вы
войдёте
или
создадите учётную запись
, её имя будет использоваться вместо IP-адреса, наряду с другими преимуществами.
Анти-спам проверка.
Не
заполняйте это!
= Example = We'll go under two examples, one sample and one real world. == Sample == Let's create a simple sample of an Autowiki. We start with the datum. The important thing to set here is the "page" variable. This will be the location of the finished product / template on the wiki. This is what people (you) will use to put your result onto your page. /datum/autowiki/my_sample page = "Template:Autowiki/Content/MyNewAutowikiSample" The only proc you MUST implement is called generate. It, well, generates the template. It's where all the code goes. /datum/autowiki/my_sample/generate() Two important procs of the datum to know are '''upload_icon''' and '''include_template'''. Another handy proc is '''escape_value'''. Let's talk about the '''upload_icon''' first. If you want to upload images as a part of your code, you can do so with this proc. We will upload an image of a lizard plushie as an example. /datum/autowiki/my_sample/generate() // Creates a lizard plushie to take a snapshot of var/obj/item/plushie/lizard/edits_the_wiki = new() // Decides the filename of the resulting PNG. var/filename = "test_lizard" // Uploads an image of the lizard to the wiki, with the file "Autowiki-test_lizard.png". // Note, attempting to split your images into subfolders will NOT work. upload_icon(getFlatIcon(edits_the_wiki, filename) Next, let's look at '''include_template''' This is the bread and butter of creating templates. We will create a table with our lizard image we just created. /datum/autowiki/my_sample/generate() var/obj/item/plushie/lizard/edits_the_wiki = new() var/filename = "test_lizard" upload_icon(getFlatIcon(edits_the_wiki, filename) ... // This is a sample of what template data might look like. // In actual practice this will be filled almost entirely automatically. var/list/template_data = list( "icon" = filename, "table_text" = "THAT is a lizard.", ) // This is essentially taking the template you pass and creating a fully filled out result with your data. // Instead of having to manually write { {Autowiki/MyNewAutowikiSampleTemplate|icon="test_lizard"|table_text="THAT is a lizard."} }, // It's just filling it on for you! // While it seems a little silly in this small sample, when you're handling hundreds of things, this saves a ton of time. return include_template("Autowiki/MyNewAutowikiSampleTemplate", template_data) The last relevant proc is '''escape_value'''. Its use is simple, it formats text in a way that won't break wikicode. Pretty much all text you're sending to the wiki should be wrapped in this proc. That's it for the datum side. All you need to do now is create the template '''Autowiki/MyNewAutowikiSampleTemplate''' how you see fit. == Real Example == See: https://github.com/tgstation/tgstation/pull/74931 . This datum goes through all soup reagent datums and extract a lot of information related to them - name, ingredients, food types, and so on. It formats them all nicely in a list, then passes the list to a template, https://tgstation13.org/wiki/Template:Autowiki/SoupRecipeTemplate . Each soup entry uses one of the above templates. Finally, when all soups are parsed through, it wraps the entire output in this template https://tgstation13.org/wiki/Template:Autowiki/SoupRecipeTableTemplate to format it in one big text: As a result, you get the following content template, automatically generated: https://tgstation13.org/wiki/Template:Autowiki/Content/SoupRecipes {{Contribution guides}} [[Category:Meta]]
Описание изменений:
Обратите внимание, что все изменения в RiftWorks рассматриваются как выпущенные на условиях лицензии Creative Commons Attribution-NonCommercial-ShareAlike (см.
RiftWorks:Авторские права
). Если вы не хотите, чтобы ваши тексты свободно распространялись и редактировались любым желающим, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений или скопировали их из источника в общественном достоянии или под совместимой лицензией.
Не размещайте без разрешения материалы, защищённые авторским правом!
Отменить
Справка по редактированию
(в новом окне)