Closed enterprisey closed 2 years ago
@enterprisey Can you please elaborate on the implementation of the second part?
What to replace the place holder?
yeah
so first we convert the citoid results to a tag, which is a pain in the butt
[ { "key": "75UNBXXE", "version": 0, "itemType": "webpage", "url": "http://www.google.com/", "title": "Google", "abstractNote": "Search the world's information, including webpages, images, videos and more. Google has many special features t o help you find exactly what you're looking for.", "accessDate": "2022-07-30", " websiteTitle": "www.google.com", "source": [ "Zotero" ] } ]
websiteTitle
, to wikipedia field names, like website
.{ "url": "http://www.google.com/", "title": "Google", "access-date": "2022-07-30", " website": "www.google.com", }
<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref>
so, if the website is google.com and the fact is asdf, then the wikitext should be as follows:
Text to Add: <syntaxhighlight lang='html'>asdf<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref></syntaxhighlight>
Rendered: asdf<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref>
{{reflist-talk}}
Here's how it would look on a wikipedia page: https://en.wikipedia.org/w/index.php?title=User:Enterprisey/sandbox2&oldid=1101384135
the placeholder is fine for now
yeah
so first we convert the citoid results to a tag, which is a pain in the butt
- take the result you got from citoid, which looks like this:
[ { "key": "75UNBXXE", "version": 0, "itemType": "webpage", "url": "http://www.google.com/", "title": "Google", "abstractNote": "Search the world's information, including webpages, images, videos and more. Google has many special features t o help you find exactly what you're looking for.", "accessDate": "2022-07-30", " websiteTitle": "www.google.com", "source": [ "Zotero" ] } ]
- fetch https://en.wikipedia.org/w/api.php?action=templatedata&titles=Template:Cite%20web&format=json and look at the pages['1252907'].maps.citoid value. it translates citoid's field names, like
websiteTitle
, to wikipedia field names, likewebsite
.- use the map to translate the object from citoid. throw out fields that don't map to anything:
{ "url": "http://www.google.com/", "title": "Google", "access-date": "2022-07-30", " website": "www.google.com", }
- turn the object into a ref tag:
<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref>
so, if the website is google.com and the fact is asdf, then the wikitext should be as follows:
Text to Add: <syntaxhighlight lang='html'>asdf<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref></syntaxhighlight> Rendered: asdf<ref>{{Cite web |title=Google |url=http://www.google.com/ |access-date=2022-07-30 |website=www.google.com}}</ref> {{reflist-talk}}
Here's how it would look on a wikipedia page: https://en.wikipedia.org/w/index.php?title=User:Enterprisey/sandbox2&oldid=1101384135
We have to do this in the backend or frontend?
You can do either, whichever one is easier. I suspect the frontend might be a bit easier.
replace "Rephrased Quote" with "Text to Add", followed by wikitext (including a properly formatted ref tag - use citoid) in a
<code>
, then the same wikitext directly included, so that it gets rendered