Changes for page Sandbox


on 2023-04-10 16:33


on 2024-05-02 05:53
Summary
Details
- Page properties
-
- Content
-
... ... @@ -14,6 +14,8 @@ 14 14 15 15 Non existing [[internal link>>notexist||style="outline-width: 0px !important; user-select: auto !important;"]] test 16 16 17 +## lc queue size ## 18 + 17 17 {{groovy}} 18 18 import com.xpn.xwiki.web.* 19 19 import org.xwiki.rendering.transformation.* ... ... @@ -23,6 +23,58 @@ 23 23 print "Link checker queue size = ${checker.linkQueue.size()}" 24 24 {{/groovy}} 25 25 28 + 29 +## lc invalid links ## 30 + 31 +{{groovy}} 32 +import groovy.util.logging.* 33 +import org.xwiki.observation.* 34 +import org.xwiki.observation.event.* 35 +import org.xwiki.rendering.transformation.linkchecker.* 36 +import com.xpn.xwiki.web.* 37 +import com.xpn.xwiki.* 38 + 39 +@Log 40 +class MyLinkListener implements EventListener 41 +{ 42 + def xwiki 43 + def context 44 + 45 + MyLinkListener(xwiki, context) 46 + { 47 + this.xwiki = xwiki 48 + this.context = context 49 + } 50 + 51 + String getName() 52 + { 53 + return "myLinkListener" 54 + } 55 + 56 + List<Event> getEvents() 57 + { 58 + return Arrays.asList(new InvalidURLEvent()) 59 + } 60 + 61 + void onEvent(Event event, Object eventSource, Object data) 62 + { 63 + def url = eventSource.get("url") 64 + def source = eventSource.get("source") 65 + def state = eventSource.get("state") 66 + 67 + log.info("Error for {url} in ${source} - Response code: ${state.getResponseCode()} - Checked: ${String.format('%tF %<tT', state.getLastCheckedTime())}") 68 + } 69 +} 70 + 71 +// Register against the Observation Manager 72 +def observation = Utils.getComponent(ObservationManager.class) 73 +observation.removeListener("myLinkListener") 74 +def listener = new MyLinkListener(xwiki, xcontext) 75 +observation.addListener(listener) 76 +{{/groovy}} 77 + 78 + 79 + 26 26 Glossary test: {{glossaryReference glossaryId="Glossary" entryId="OTE"}}OTE{{/glossaryReference}} is an entry, but OTP is not. 27 27 28 28 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!