Latest revision |
Your text |
Line 35: |
Line 35: |
| | | |
| local lookup = { | | local lookup = { |
− | argumentation2 = "annotator-hl-blue", | + | argumentation = "annotator-hl-blue", |
− | innovationsdiskurs2 = "annotator-hl-red", | + | innovationsdiskurs = "annotator-hl-red", |
− | narrativ2 = "annotator-hl-lime", | + | narrativ = "annotator-hl-green", |
− | wissenschaftlichereferenz2 = "annotator-hl-yellow", | + | wissenschaftlichereferenz = "annotator-hl-yellow" |
− | beispiel3 = "annotator-hl-blueviolet",
| |
− | praemisse3 = "annotator-hl-orange",
| |
− | schlussfolgerung3 = "annotator-hl-cyan"
| |
| } | | } |
| local title = mw.title.makeTitle('', pagetitle) | | local title = mw.title.makeTitle('', pagetitle) |
Line 65: |
Line 62: |
| local category = metadata['category'] | | local category = metadata['category'] |
| category = category:lower() | | category = category:lower() |
− | category = category:gsub("%d%_", "")
| |
− | category = category:gsub("ä", "ae")
| |
− | local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb"
| |
− | local prefix = '<div class="' .. "box-layer2 " .. selector .. '">'
| |
− | local suffix = "</div>"
| |
− | local prefix_title = '<span class="box-layer2-title' .. '">'
| |
− | local suffix_title = '</span>'
| |
− | rv = rv .. prefix .. prefix_title .. metadata['category'] .. suffix_title .. '<br>' .. "" .. metadata['quote'] .. suffix
| |
− | t[i] = _xpathToSortableIndex(start)
| |
− | end
| |
− |
| |
− | table.sort(t)
| |
− |
| |
− | -- local page = mw.title.makeTitle('', annotationspage)
| |
− | -- local content = page:getContent()
| |
− |
| |
− | -- Todo: sort annotations by position in text by the use of XPATH info in metadata
| |
− | -- local result = ""
| |
− | --for i, e in ipairs(t) do
| |
− | -- result = result .. e .. '<br>'
| |
− | --end
| |
− | return rv
| |
− | end
| |
− |
| |
− | return 'should not have reached this point'
| |
− | end
| |
− |
| |
− | function p.ExtractLayer3(frame)
| |
− |
| |
− | -- get title from arguments
| |
− | local pagetitle = frame.args[1]
| |
− | pagetitle = 'Text:' .. pagetitle:gsub("Annotationen:", "")
| |
− | if pagetitle == nil then
| |
− | return 'No title supplied as parameter'
| |
− | else
| |
− |
| |
− | local lookup = {
| |
− | argumentation2 = "annotator-hl-blue",
| |
− | innovationsdiskurs2 = "annotator-hl-red",
| |
− | narrativ2 = "annotator-hl-lime",
| |
− | wissenschaftlichereferenz2 = "annotator-hl-yellow",
| |
− | beispiel3 = "annotator-hl-blueviolet",
| |
− | praemisse3 = "annotator-hl-orange",
| |
− | schlussfolgerung3 = "annotator-hl-cyan"
| |
− | }
| |
− | local title = mw.title.makeTitle('', pagetitle)
| |
− | local pagecontent = title:getContent()
| |
− |
| |
− | local query = '[[Annotation of::' .. pagetitle .. ']]|?=#|?AnnotationMetadata=#'
| |
− | local result = mw.smw.ask(query)
| |
− | local rv = ''
| |
− | local t = {}
| |
− |
| |
− | if result == nil then
| |
− | return 'No annotions found for page ' .. pagetitle
| |
− | end
| |
− |
| |
− | for i=1,#result do
| |
− | -- result[i][1] -> title of page
| |
− | -- result[i]['#'] -> metadata
| |
− |
| |
− | local metadata = result[i]['#']
| |
− | metadata = _annotationMetadataExtract(metadata)
| |
− | local start = metadata['ranges'][1]['start']
| |
− | local startoffset = metadata['ranges'][1]['startOffset']
| |
− | local category = metadata['category']
| |
− | category = category:lower()
| |
− | -- rv = rv .. category .. ' ' .. lookup[category] .. '\n\n'
| |
| local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb" | | local selector = type(lookup[category]) == "function" and lookup[category]() or lookup[category] or "blubb" |
| local prefix = '<div class="' .. "box-layer2 " .. selector .. '">' | | local prefix = '<div class="' .. "box-layer2 " .. selector .. '">' |