How to get the current URL in a Confluence Macro? - velocity

I am using Confluence and I am trying to build a User Macro (using Velocity). I would need a way to obtain the current page URL and use it as a variable. I need the whole URL (ex: http://confluence.idi.local/display/~mircea/Testing+Macros). Is there a way to achieve this? Been looking for 2 days now and I couldn't find anything...
Thank you

Found it:
$action.getGlobalSettings().getBaseUrl()$content.getUrlPath()
This will display the complete URL of the page where the macro is executed.

If you not just want the configured base url, you can also use the HttpServletRequest in the execute method, as described here:
How do I get hold of the HttpServletRequest?

Related

Qlikview URL parameter selection not working due to cache

I am trying to embed a Qlikview chart in a custom webpage via an iframe - using singleobject.htm. I want to apply a certain filter so i am passing "&select=LB186,CSP" where LB186 is the listbox in the actual qlikview document.
This "select" paramater in the URL doesnt seem to work because of caching. I also tried to replace LB186 by the actual field name, that did not work either.
I want to somehow clear cache and load the page as a fresh reload. appending a random var=XXX hack also doesn't work. Any clue?
You can try to use bookmark instead
alternative url below, please remember that here document part is url encoded:
https://$servername/qvajaxzfc/authenticate.aspx?type=html&try=/qvajaxzfc/singleobject.htm?document=example.qvw%26object%3DDocument\CH1&back=/LoginPage.htm&webticket=$ticket

Auto login to website using script or bookmark

I've been trying to figure this out using various different methods. I'm trying to create a script/bookmark or some type of quick action to open a browser tab or window with a specific URL, and automatically log me in using my credentials. I'm not all that concerned about security for this at the moment.
At first I figured I'd try to use a javascript bookmark to do this, but nothing I found in my research worked. Next I tried to create a bash script, but I couldn't figure out how to send the credentials in via the terminal. Most recently, I literally copied the source code of a site, created a local file and tried to hack together something where I could prefill the form data with credentials and use JS to submit the form, and I've gotten close with this, but for some reason when I use the JS submit function, it errors out and says that the username and password are invalid. But when i turn off the submit function and manually click "log in" on my local html page, it works as expected. I want this to be a one click process, so the idea of using onload/submit or something to that affect is really important to me.
The site I'm testing with has a Rails backend and my next attempt might be trying to use POST to do what I'm thinking, but that's currently outside of my level of knowledge on the subject.
Anyone answering: i do not want to use a password manager to accomplish this.
My requirement is that i will either be able to a) run a script or b) use a 1-click option to do this per website. Ideally i'd be able to set this up in a sort of programmatic way to do this with multiple sites, but I'd be happy with 1 at the moment.
i know similar questions have been answered before, but I haven't been able to use information from those posts (the ones I've seen anyway) to figure out a good way to do this.
Create a bookmark for the current page you have opened.
Edit the bookmark
Change the value for the URL to something like this.
(javascript:(function(){CODE_GOES_HERE_FROM_BELLOW})();
find the field for username and password on the page.
Given example for hotmail
var inputs = document.getElementsByTagName('input'); for(var i=0;i<inputs.length;i++){if(inputs[i].name === 'passwd'){inputs[i].value = 'YOUR_PASSWORD'}else if(inputs[i].name === 'loginfmt'){inputs[i].value = 'YOUR_USERNAME'}}; document.getElementById(document.getElementsByTagName('form')[0].id).submit();
OR
try out casperjs.
The proposed solution didn't work for me and rather than spending tons of time installing a testing framework that I'll never use other than for this purpose, I decided to try to do this another way.
First, I found out that the reason my JS wasn't working before is because the site did not allow a JS submit to be done, or atleast that's what it seemed to be when I got this error: "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience"
The javascript I was using was in fact working, just not submitting. I used the following code to fill the fields (using "Class Name" elements on the page since there was no name or ID):
document.getElementsByClassName('username')[0].setAttribute('value', 'user');
document.getElementsByClassName('password')[0].setAttribute('value', 'password');
As I mentioned, the problem was when I tried to use JQuery to submit the form: document.getElementsByClassName('loginForm')[0].submit();
Which is when the above error cropped up. I can't really say for sure whether this is the root of the cause, but the page does submit, but I get an invalid username/password error when I do
I haven't figured out a great way to get around this just yet, but my short-term, "hacky" solution was to use Applescript to send a return keystroke to the browser to submit the form. I'd ideally like to figure out how to get the submission to work using JQuery, but I'm not sure how to get around it.

Yii how to redirect to particular URL

I have used url beautifier to remove index.php?r= from URL. it works fine.
now i want user to redirect to URL if user hits particular url.
suppose
http://localhost/xm/xmds.php?wsdl
To
http://localhost/xm_demo_menu/WebService/service
how to achieve this. i search lot on google but not found material relevant to my problem
any suggestions ?
I do not see where the problem should be. See documentation
In you controller, simply call:
$this->redirect("http://localhost/xm_demo_menu/WebService/service");

Setting a default element in SOAPUI

I've been using SOAPUI a lot lately and noticed that there are some elements I want to set for all request, such as an API key, or a date range.
Is there a way to automatically do this?
example: Every request begins with:
?
Is there a way to automatically fill in the api key for every request?
thanks.
I think the answer is No.
But you can try playing with defining properties. You can set properties at project level and then use the property everywhere you need.
It is not automated - you have to use the property correctly everywhere you need it.
In the project tree on the left you see all your WSDLs and its operations. Right click on an operation and choose New request.
Open the new request and set the default properties you want. Now you have two possibilities.
Add to TestCase
Right click on the request and choose that option. Then you can choose the TestCase to which you want to add the request.
Copy to TestRequests
Right click on the request and choose that option. Now you can choose existing TestRequests to which you want to add the values of the given request. I haven't used that option till now. You have to try if it works as expected.

Get text from a section on some page

I know how to make an API call to get me the text of the whole page, like this, but is there a way (without having to parse through the wiki markup) to only get the text from a certain section?
If you look at the documentation for the revisions module, you'll notice that it has a prameter rvsection, which is exactly what you want. So, for example, to retrieve the lead section, use
http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=Stack%20Overflow&prop=revisions&rvprop=content&rvsection=0