Confluence Plugin: How to create space and pages programmatically from imported CSV? - plugins

I want to add a button to the system.header/left, which I already did. And when I click that button, I want a file picker popup to choose my CSV.
From the CSV content, I want to create space and pages.
I've browsed through the documents and tutorials, but I can't find anything alike.
Could you point a direction or steps for me? At least, point me to something relevant?.

Here's a short overview:
Your button will trigger a JavaScript.
That javaScript will open a dialog window containing the form elements allowing the file upload
The target of that form will be either a servlet or rest-endpoint
inside your plugin. Let's assume it's a servlet.
The servlet will
take the submitted file, split it using the defined separator and
create the page structure using the confluence API calls.
And forward to the start page of your new Space.
I'd suggest that you start with the servlet.
Provide a couple of lines of test data, to check if your code creates the page structure as expected.
Once this works, add the file handling part (from a dedicated html) and pass the data to your existing function.
Now, you have the backend and the frontend, so rendering the dialog when your button is clicked, is pretty straight forward.
Make sure to display the button only if the current user has the right to create a space.
Stuff that might help you:
confluence servlet module: https://developer.atlassian.com/server/confluence/servlet-module/
reading a CSV in java: https://www.baeldung.com/java-csv-file-array
Uploading a file in Java: https://www.baeldung.com/upload-file-servlet
How to create a new Space using Java API: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-create-a-Confluence-Space-with-Java-API/qaq-p/491588
Confluence API: SpaceManager: https://docs.atlassian.com/atlassian-confluence/6.6.0/index.html?com/atlassian/confluence/spaces/SpaceManager.html
Confluence API: PageManager: https://docs.atlassian.com/atlassian-confluence/6.6.0/index.html?com/atlassian/confluence/pages/PageManager.html
Hope this helps.

Related

Import an HTML file as a Confluence page

I have stored some pages that I have created in Confluence (with an account that doesn't exist anymore) as HTML files a while ago.
I would like to use them in another Confluence account. There are often lots of mathematical expressions within the texts so I cannot simply copy the content of the html files and paste them into the Confluence page (right?).
Is there a way to proceed conveniently?
I noticed that the former Confluence pages are stored as folders with multiple files in it which are mainly of the following file formats: .css and .Download.
screenshot:
You can try the following:
log into confluence
click on Create
click on Import (to the right next to Templates)
pick the right option
More official info here:
https://community.atlassian.com/t5/Confluence-questions/How-to-Export-Import-Confluence-Pages-and-Spaces-plus-Jira/qaq-p/1022504

Generate multiple sheets in one pdf file

I am trying to generate a pdf from a Tableau workbook which has two sheets using the url method:
E.g: https://TableauServer/views/workbook/sheet1?:format=pdf&parameter=value
I am doing this in a program which will issue the url request to the url. The url works fine for one sheet. But the problem is how to generate one pdf file with both sheets in it?
If you first put your two sheets into a single dashboard and then use the URL for the published dashboard (still using the format=pdf parameter), this should work just fine.
We know it's possible because within the Tableau pages itself if you download a PDF it gives you several formatting options, including the option to put all the worksheets in a workbook into a single PDF.
I couldn't find any documentation on it though. What I ended up doing was looking at the network console in the browser (usually F12) when I downloaded the PDF from the browser by clicking the Download button. That showed me the URL end point and the JSON body the server expected in the request payload.
The endpoint URL wasn't too cryptic and ended with "commands/tabsrv/pdf-export-server". The challenge was to take the JSON in the request payload and find the right settings to get it into a single PDF.
This method is a more technical approach and requires very little coding skills; any language that has functions for http calls will work (I use python for it).
If you don't mind doing it outside a browser, tabcmd has lots of functionality to control PDF generation at the command line.

Sails how to use templates, server side

I have already worked using Sails.js. But in that project we used it simply as an API. We had backbone on a client side.
In the new application I am planning to use Sails from bottom to top, and I have some things I do not fully comprehend.
I have views that use templates (EJS). In my controller I can call a view and pass it a model to render. That I understand. What I am dont fully understand is where do I put javascript files for a client in this scenario?
For example, lets assume that I have a view that has a input box and a button. I would want to have some javascript that controls that button and input (validation or whatever). Lets assume I put that code for input box and button in a validation.js:
1. In what location do I put that file? Assets?
2. How do I include that file to be sent to client for execution? Do I include it in a template.ejs using normal < script > tags?
All the client assets should be placed into the assets folder.
All the includes are automatically binded by Grunt (when lifting the server) into the layout.ejs file, if you've put your css files into the assets/styles folder and your js files into the assets/js folder.

Where does orbeon form saved?

I am a new user of orbeon and am trying to some exercise with orbeon's code. I have downloaded orbeon source code from git. I have made a war file (with ant orbeon-dist-war) and placed it in tomcat. Everything is working fine. Then I follow the tutorial and make "my-bookcast" application mentioned there.I found the application source code at "/WEB-INF/resources/apps/my-bookcast" and I know which database is used and where the data are saved. But my questions are
When I create form using orbeon form builder using the video tutorial mentioned in www.orbeon.com, using mouse and keyboard only where the form saved? How can I see the source code (like "my-bookcast") of the saved form?
Can I use the form along with source code in other application, independent off orbeon?
Update: Can anyone tell me, if I want to see the data stored in exist-db then how can I do this. I heard about oxygen, which can be used as a exist-db browser. In that case where can I found the exist-db related configuration in orbeon to connect with the built-in exist-db?
Out of the box, the form definitions and form data are stored into the embedded eXist database. The source code you can see directly from Form Builder, with "Edit Source".
No.
Regarding the question in your update: you can disable the orbeon-exist-filter eXist security filter in web.xml, then should be able to connect with oXygen either via exist-xmlrpc-servlet or exist-rest-servlet which is mounted on /exist/rest/*.
Graphical view
You can find this icon on Right Top.
After clicking, you will get this popup and that's the source

Zend_Translate Help - Slovak Languege

I need to just translate form error messages in my application.
The application is not multilingual, it is al in Slovak (so I already write labels and stuff in Slovak language), just need to translate error messages.
I have made this method in my bootstrap file:
protected function _initTranslate()
{
$this->translate = new Zend_Translate('gettext',
'/path/to/translation/source-sk.mo',
'sk');
Zend_Form::setDefaultTranslator($this->translate);
}
But how to create the source-sk.mo file? Do I need to download it somewhere from the Web?
First you will need to download the PoEdit software and then you will need to configure it according to this post.
Once you have completed those steps, you will need to create a new catalog file from within PoEdit. In the creation dialog, click on the keywords tab, and then add function names that you wish to scan for in your code. With Zend Framework, this is typically just translate since you are probably using the translate() view helper. However you will want to also include setLabel so that it pulls your Zend_Form labels as well.
After you have created your catalog, you will need to scan your source code for translations. You do this by clicking Update from Sources under the Catalog menu. Once it has completed scanning your source code, it will display a list of all strings that need to be translated. You then go down the list and enter in the translation for each string. Now save the catalog to somewhere within your ZF application, preferably /languages, point your Zend_Translate declaration to this location and you are good to go.
If you adjust any labels or strings later on, you can always reopen the catalog with PoEdit, run Update from Sources again and it will pull all of the new changes for you to translate.