Changes for page Get in Touch About Your XWiki Project
Last modified by Alex Cotiuga on 2026/07/27 06:09
From version 18.6
edited by Alex Cotiuga
on 2026/07/09 19:54
on 2026/07/09 19:54
Change comment:
There is no comment for this version
To version 18.25
edited by Alex Cotiuga
on 2026/07/09 20:47
on 2026/07/09 20:47
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (0 modified, 1 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -121,12 +121,15 @@ 121 121 122 122 ## Save only known ContactRequest fields. 123 123 #foreach ($parameterName in $request.parameterNames) 124 + #if ($parameterName == 'sourcePage') 125 + #set ($discard = $contactRequestObj.set($parameterName, $stringtool.trim($request.get($parameterName)))) 126 + #end 124 124 #set ($propertyParts = $parameterName.split('_0_')) 125 125 #if ($propertyParts.size() > 1) 126 126 #set ($propertyName = $propertyParts[1]) 127 127 128 128 #if ($allowedProperties.contains($propertyName)) 129 - #set ($discard = $contactRequestObj.set($propertyName, $request.get($parameterName))) 132 + #set ($discard = $contactRequestObj.set($propertyName, $stringtool.trim($request.get($parameterName)))) 130 130 #end 131 131 #end 132 132 #end ... ... @@ -163,15 +163,16 @@ 163 163 ## As a measure to avoid high load on website. 164 164 Tell us more about your project at <a href="mailto:alex@agnease.com">alex@agnease.com</a> 165 165 #else 169 + #set ($hiddenProperties = ['sourcePage']) 166 166 <form id="contactForm"> 167 167 <dl> 168 168 #foreach ($property in $xclass.properties) 169 - #if ($property.name == 'hosting')170 - <hr>171 - <h3>Optionalprojectdetails</h3>172 - < p>These detailshelpus understand the scopeandsuggestpracticalnextsteps.</p>173 - #end174 - <div>173 + #if (!$hiddenProperties.contains($property.name)) 174 + #if ($property.name == 'hosting') 175 + <hr> 176 + <h3>Optional project details</h3> 177 + <p>These details help us understand the scope and suggest practical next steps.</p> 178 + #end 175 175 <dt #if (!$editing && $hasEdit) 176 176 class="editableProperty" 177 177 #set ($xobjectPropertyReference = $xobject.getPropertyReference($property.name)) ... ... @@ -186,7 +186,7 @@ 186 186 <span class="xHint">$!escapetool.xml($services.localization.render($property.hint))</span> 187 187 </dt> 188 188 <dd>$doc.display($property.name, 'edit').replace('{{html clean="false" wiki="false"}}', '').replace("{{/html}}", '')</dd> 189 - </div>193 + #end 190 190 #end 191 191 #if (!$xclass.properties || $xclass.properties.size() == 0) 192 192 ## Keep the empty definition term in order to have valid HTML. ... ... @@ -207,6 +207,7 @@ 207 207 /> 208 208 </div> 209 209 <input type="hidden" name="Agnease.Code.ContactRequest.ContactRequestClass_0_contactStartedAt" value="$datetool.systemDate.time" /> 214 + <input type="hidden" name="sourcePage" /> 210 210 <input id="contactSubmit" type="submit" class="btn btn-primary" value="Send my request"> 211 211 </form> 212 212 #end
- XWiki.JavaScriptExtension[1]
-
- cache
-
... ... @@ -1,0 +1,1 @@ 1 +long - code
-
... ... @@ -1,0 +1,32 @@ 1 +require(['jquery'], function ($) { 2 + $(function () { 3 + var sourcePageField = $('input[name="sourcePage"]'); 4 + 5 + if (!sourcePageField.length || sourcePageField.val()) { 6 + return; 7 + } 8 + 9 + if (!document.referrer) { 10 + return; 11 + } 12 + 13 + try { 14 + var referrerUrl = new URL(document.referrer); 15 + 16 + if (referrerUrl.origin !== window.location.origin) { 17 + return; 18 + } 19 + 20 + var sourcePage = referrerUrl.pathname 21 + .replace(/^\/bin\//, '') 22 + .replace(/\/$/, '') 23 + .replace(/\//g, '.'); 24 + 25 + if (sourcePage) { 26 + sourcePageField.val(sourcePage); 27 + } 28 + } catch (e) { 29 + // Ignore invalid referrer values. 30 + } 31 + }); 32 +}); - name
-
... ... @@ -1,0 +1,1 @@ 1 +document referrer catcher - use
-
... ... @@ -1,0 +1,1 @@ 1 +currentPage