This is a ColdFusion application that has many email functionalities embedded with specific application links.
Need to know how to store the target link in the application that doesn't change with the entire session.
Is it possible to use the target query in the link to redirect to the saved target link?
Sample code:
Page1 code
cfset objRequest = GetPageContext().GetRequest()
cfset strUrl = objRequest.GetRequestUrl().Append("?" & objRequest.GetQueryString()).ToString
All other pages will have the page1 loaded like this:
cfinclude template="../xxx/Page1.cfm"
so each time the page1 is loaded the strUrl value keeps changing. Need help to know where and how can I actually store the strUrl value on the first hit.
Related
I created a personal CMS project where each page is stored in the database with the following columns: title, url_safe_title, and content.
To create the url_safe_title, I used urllib.parse.quote() on the original title. So if the page title is "My Page", the url_safe_title will be stored as "My%20Page".
On templates, I'd build URLs using url_for('core.page', page_name = page.url_safe_title), where page_name is the expected variable in the view function.
#core.route('/<string:page_name>')
def page(page_name):
# find the relevant entry in db
return render_template('template.html', page = page)
However, the resulting URL becomes "www.example.com/My%2520Page" instead of the expected "www.example.com/My%20Page". I checked the url_safe_title value stored in the database, and it's the correct value ("My%20Page").
Interestingly, "My%2520Page" worked when trying to query for a page that has url_safe_title as "My%20Page" when I was hosting this app locally. However, it all fell apart when I hosted it online. Unfortunately, the host is a limited cPanel host without any access to the terminal, so I'm unable to find out what the OS is. I only know that the python version is 3.7.8, and my local python version is 3.7.4.
I've also tried using the |safe jinja filter when building the URL url_for('core.page', page_name = page.url_safe_title|safe), but that didn't help either. I passed the page.url_safe_title as a variable on its on to show on the page, and "My%20Page" was displayed.
%2520 means it is getting encoded twice. You should not encode it before storing in the database. It is just a string.
I'm trying to scrape google search results using python and selenium. I'm able to get only the first search result. Here is the code I'm using.
driver.get(url)
res = driver.find_elements_by_css_selector('div.g')
link = res[0].find_element_by_tag_name("a")
href = link.get_attribute("href")
How can I get all the search results?
Try to get list of links (from first page only. If you need to scrape more pages, you need to click "Next" button in a loop and append results from following pages) as below:
href = [link.get_attribute("href") for link in driver.find_elements_by_css_selector('div.g a')]
P.S. You also might use solutions from this question to get results as GET request response with requests lib
I've created a new page Aikau, but I changed the XML file and the rendered page content between the standard Share header and footer disappeared.
In this page, I want the arguments of the query string, so I write this code:
page.get.desc.xml:
<webscript>
<shortname>My New Page</shortname>
<url>/hdp/ws/my-new-page</url>
<authentication>user</authentication>
</webscript>
page.get.js:
function main ()
{
// Get the args
var fileProp = args["test"];
model.temp = fileProp;
}
main();
page.get.html.ftl:
Test arg: ${temp}
I have to put /hdp/ws/my-new-page in the XML file to write the content of FTL file in this page... But why did the header and footer of the Alfresco template disappeared ? hdp serves for this purpose. And if I don't put the URL like that on the XML, the page appears with the template.
What is wrong in my code? Or how can I recover the template? Or add header and footer?
EDIT: I already try to put only /my-new-page without /hdp/ws/ but the args are null when I put /hdp/ws/. Give me a hint.
EDIT2: I already try to import alfresco-template.ftl but I can't. Any idea?
You don't actually need to include the the "hdp/ws" part in your WebScript descriptor. Only the "/my-new-page" is required. Aikau attempts to simplify the Surf page creation by providing a number of pages out-of-the-box (and the "hdp" page is just one of them).
Aikau uses URI-template mapping to match a single WebScript to a page, so for example in the URL:
/share/page/hdp/ws/my-new-page
share = application context
page = Spring MVC request dispatcher
hdp/ws/my-new-page is then mapped to the URI template:
<uri-template id="share-page">/{pageid}/ws/{webscript}</uri-template>
Where "hdp" is the id of the page to render and "my-new-page" is the WebScript URL. The HDP page uses the "webscript" token from the template to automatically create a new Surf Component and bind it to the WebScript.
But in short - don't include "hdp/ws" in your WebScript URLs for Aikau pages.
You need to make the things that you have on javascript server in this javascript mandatorily? If not, you can create a javascript client that receive the same arguments (location.search give to you the query string, so, you can make parse of that query string and get only the value of the "test" that you want) and call them on FTL file (the client-side javascript). So, when the page loading, it does not lose the arguments. It isn't the best solution but you can try this...
Here is what I want to accomplish:
I am writing a script which will parse some source code, extract some comments that I want it to extract and I will store this text in a text file.
I want to write another script that uses the content of this text file to be programatically transformed into a Confluence wiki-page.
Please tell me the best way to do this. I already saw this
I felt that I could change the input in the above example to take input from text file and update contents of Confluence page. But, I am not sure how it will be formatted. If I have to format it, what do I need to do?
Thanks in advance!
As an alternative to XML-RPC you can use the integrated WebDAV plugin.
Write a script that creates a directory in the selected space.
The directory name will be the page name. After creating the directory a text-file with the same name (with .txt extension) will be created in the directory which holds the content of the page
let your script edit this file in insert the content of your text-file.
Information about the usage of the plugin:
Configuring a WebDAV client for Confluence
Confluence WebDAV Plugin
Troubleshooting WebDAV
I Also saw the code you are referring to. I tweaked it a bit a produced the following code that me help you for the second part of your question.
My code creates a new space and also a new page from a text file that is inserted in the previously created space.
import sys
import xmlrpc.client
import os
import re
# Connects to confluence server with username and password
site_URL = "YOUR_URL"
server = xmlrpc.client.ServerProxy(site_URL + "/rpc/xmlrpc")
username = "YOUR_USERNAME"
pwd = "YOUR_PASSWORD"
token = server.confluence2.login(username, pwd)
# The space you want to add a page to
spacekey = "YOUR_SPACENAME"
# Retrives text from a file
f = open('FileName.txt', 'r')
content = f.read()
f.close()
# Creates a new page to insert in the new space from text file content
newpage = {"title":"NEW_PAGENAME", "space":spacekey, "content":content}
server.confluence2.storePage(token, newpage)
server.confluence2.logout(token)
For your formatting issues, html is supported, but I have not quite figured out how to use CSS styles other than inline (everthing else does not seem to work).
These styles work when you write them with the HTML macro inside Confluence, but from the remote API, it does not seem to behave the same way.
UPDATE :
You can use the {html} macro to include your html by using :
content = server.confluence2.convertWikiToStorageFormat(token, content)
You can also specify your CSS in your global CSS stylesheet.
Another option is to develop a plugin to include a CSS resource :
https://developer.atlassian.com/display/CONFDEV/Creating+a+Stylesheet+Theme
I have tried this way and works petty well for me:
I used a Java program to created a programmatic client to create the dynamic content. This created a HTML document out of my plain text.
I used a RPC client connected to Confluence to uploaded it as a new page.
Your html will be preserved. But if you want to add CSS or JS/JQuery etc on top of your html you will need to create a Macro and enable it for the Particular page. This feature is not available in Confluence OnDemand.
I need to set a cookie in IE to execute some specific flow. I tried using the following code
ieb = Watir::IE.new
ieb.document.cookie="rememberme=foobar;Path=/; Domain=sometestdomain.com"
# Bring up browser and do bunch of stuff
However, I see that when the IE comes up, rememberme cookie is not set. Am I doing something wrong here?
You need first open browser with some document loaded from sometestdomain.com.
Then you'll be able to set cookies.