I have a process that automatically attaches a file to a wiki page, and now I want to embed that text file into the page contents itself. Is there an equivalent to the {include} macro for text file attachments?
Hi, its just about 2015 - does anyone know of a solution for this use case?
If the question is still actual:
there is a macro (named "SQL Table Transformer") that can do that: see it on Marketplace (https://marketplace.atlassian.com/apps/1219300/sql-powered-table-transformer?hosting=server&tab=overview)
Once the macro installed, add the macro container to your desired page. Then you will need to configure it a bit:
1. While editing the page, click the macro container, then click Edit. In the "Input" tab of the macro container configuration enable the "Resolve Wiki Paths in Input URLs" checkbox.
2. Click the "SQL" tab. Replace the default SQL with the following:
SELECT * FROM CSVREAD(':^attached_file_name.ext#0');
or (this will give a slightly different result):
SELECT FILE_READ(':^attached_file_name.ext#0', NULL) "Content";
where:
3. Now, click the "Output" tab and set "Bring Results As" selector to "Table CSV"
4. Try it (click Refresh) in the preview (the container should bring you the contents of the file on your page).
You can play with other settings as well.
5. If satisfied, save the macro configuration and the page.
Some SQL Table Transformer macro pages with additional info:
1. general overview: https://v-and-b.atlassian.net/wiki/spaces/PD/pages/229981/SQL+Table+Transformer+Macro+for+Confluence
2. user guide: https://v-and-b.atlassian.net/wiki/spaces/PD/pages/763232257/SQL+Table+Transformer+Macro+for+Confluence+User+Guide
Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks everyone for your suggestions. Charles solution was the closest to what I am wanting to do. I created a user macro as suggested in the forum thread, and the solution is working in Google Chrome. On IE and Firefox it is more problemmatic. Seems like they each handle the <embed> tag slightly differently.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're only going to be accessing text files then you don't need to restrict yourself to the <embed> tag. An alternative is to use jQuery (client side code) to retrieve the contents of the attachment and insert it into another element, such as a div.
Here's an example to help you: http://stackoverflow.com/questions/6470567/jquery-load-txt-file-and-insert-into-div
You wouldn't need the button-click trigger, just make the ajax call within the (document).ready() block.
I would expect this to overcome any browser specific issues.
I'd be interested in your finished solution if you could post it back here, as would others I expect. :)
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
James, rather than attaching to a page, why dont you put the contents itself directly into the page, using the Confluence CLI?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I meant the Confluence Command Line Interface from Bob Swift. https://bobswift.atlassian.net/wiki/display/ACLI/Atlassian+Command+Line+Interface
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I too would like to see something list the "View File Macro" for text files (http://confluence.atlassian.com/display/DOC/View+File+Macro).
For example:
{viewdoc:name=my document.doc} {viewppt:name=my presentation.ppt} {viewxls:name=my spreadsheet.xls} {viewpdf:name=my document.pdf}
But I would like to be able to do this with a text file like this:
{viewtxt:name=myfile.txt}
I have lots of text file scripts that I want to display in confluence pages, but I don't want to have to edit, copy, and paste every single script. I just want to upload them as attachments to one page and then reference them in other pages. Much easier to upload a text file script after I have changed it than having to edit every single page and do the edit, copy, paste steps.
--- @ James Hines
Would this work around work for you? I know it is a stretch, and I'm not sure if this would produce the results you would want to see, but could you put your content in one cell of an Excel Speadsheet and then use this macro to display the content?
{viewxls:name=Book1.xls|sheet=Sheet1|row=0|col=0}
Good luck...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see the following options:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
swiniak,
Thanks for the response, but it really wasn't very helpful. Yes, there are lots of thing that I could do myself, but I was looking for someone that has already solved this problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well... you did not state you wanted a working solution. I just gave some tips on how can you do it (which could be helpfull if you're not too familiar with Confluence)... so now you'll just need to wait for another response or you can start working on it yourself :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.