Changes for page Sandbox


on 2022-11-09 07:09


on 2022-11-01 05:01
Summary
Details
- Page properties
-
- Content
-
... ... @@ -6,10 +6,7 @@ 6 6 7 7 External Link ([[bad>>https://files.quagmyre.com/nosuchfile.html]]) 8 8 9 -Linkchecker: [[here>>XWiki.ExternalLinks]] 10 10 11 -Non existing [[internal link>>internal link||style="outline-width: 0px !important; user-select: auto !important;"]] test 12 - 13 13 {{groovy}} 14 14 import com.xpn.xwiki.web.* 15 15 import org.xwiki.rendering.transformation.* ... ... @@ -19,8 +19,56 @@ 19 19 print "Link checker queue size = ${checker.linkQueue.size()}" 20 20 {{/groovy}} 21 21 22 -Glossary test: {{glossaryReference glossaryId="Glossary" entryId="OTE"}}OTE{{/glossaryReference}} is an entry, but OTP is not. 23 23 20 +{{groovy}} 21 +import groovy.util.logging.* 22 +import org.xwiki.observation.* 23 +import org.xwiki.observation.event.* 24 +import org.xwiki.rendering.transformation.linkchecker.* 25 +import com.xpn.xwiki.web.* 26 +import com.xpn.xwiki.* 27 + 28 +@Log 29 +class MyLinkListener implements EventListener 30 +{ 31 + def xwiki 32 + def context 33 + 34 + MyLinkListener(xwiki, context) 35 + { 36 + this.xwiki = xwiki 37 + this.context = context 38 + } 39 + 40 + String getName() 41 + { 42 + return "myLinkListener" 43 + } 44 + 45 + List<Event> getEvents() 46 + { 47 + return Arrays.asList(new InvalidURLEvent()) 48 + } 49 + 50 + void onEvent(Event event, Object eventSource, Object data) 51 + { 52 + def url = eventSource.get("url") 53 + def source = eventSource.get("source") 54 + def state = eventSource.get("state") 55 + 56 + log.info("Error for {url} in ${source} - Response code: ${state.getResponseCode()} - Checked: ${String.format('%tF %<tT', state.getLastCheckedTime())}") 57 + } 58 +} 59 + 60 +// Register against the Observation Manager 61 +def observation = Utils.getComponent(ObservationManager.class) 62 +observation.removeListener("myLinkListener") 63 +def listener = new MyLinkListener(xwiki, xcontext) 64 +observation.addListener(listener) 65 +{{/groovy}} 66 + 67 + 68 + 24 24 The sandbox is a part of your wiki that you can freely modify. It's meant to let you practice editing. You will discover how page editing works and create new pages. Simply click on **Edit** to get started! 25 25 26 26 {{info}}