CK Editor JSON file creation for inserting images - json

I am using CK Editor on my web site and have built a simple uploader script in php to add images to my server. I am using the image browser plugin to enable the inclusion of images into my text. The image browser seems to work using a JSON file which must list all images in the image folder.
I am completely new to JSON and to get around learning how to build a JSON file I created a PHP file which simply reads the names of my images from a database and includes them in the JSON file.
This, as a workaround seems to be perfectly functional, however it is reliant on my upload script having to add the image names to the database (an unnecessary step) and it is also bad practice.
I am looking for a good tutorial or explanation on how to make a very simple JSON file which lists the images in my uploads folder in the correct format for CK Editor so that I can free myself from my image names database and program like a big boy.
Any and all help would be apreciated.

Related

Angular 5 : How to integrate html data (which is a formatted text) in a .docx file?

I'm still a bit newbie in the code game, and i would like some advices from senpai.
Context :
I'm making a angular 5 app which has a form, which is using also QuillJS, a rich text editor for only one question (the previous questions are simple input field for strings or numbers). My goal is to allow my users to download the form and the text from QuillJS they completed, on a .docx file (Word). And of course i'm doing this because i want to keep the formatted text from QuillJs, otherwise i would have just get a good ol' string.
Issue :
The point is, i'm already building a docx file for the first questions of the form and the only method i found for now to put my html string from QuillJs in a Word readable data type, is to use html-docx-js library.
This post even explain how. But, BUT, i don't want to use saveAs function (see the post), that create a file and put the content in it. I want to put the content in the docx file i'm already creating.
So here is my question, how would you, senpai, do it ?
The thing is that i've got a Blob file (cf post), but i don't know how to put it in my docx file. I tried to see if FileReader function could do the job, but well... i don't get how to integrate this special Blob file type (which is : application/vnd.openxmlformats-officedocument.wordprocessingml.document) in the docx file.
Maybe there is another way, i'm open to any suggestions, i don't mind at all to change my way of doing.
Thank you. Save internet, give me a tip.
The official documentation for html-docx-js does not state any other options than the asBlob method. I suggest two options:
Decoding the DOCX:
The Blob filetype is not special. The blob is just binary representation of the docx. I found in SE question that the docs in fact zipped XML document. You could unzip it using JSZip or other JS solution, then read it using FileReader and try to deal with it in a DOM manner. I'm not qualified to go into details how that could work.
Adding HTML to the user input first and then outputting it as a whole
This is changing the way you want to do it. In this way, I would first create formatted HTML with the data you collected in other parts of the questionnaire. Then you append the rich data from the rich editor. At last you take this HTML data and save it into single file using the asBlob function.
The second solution will maybe strip some customization from your original approach, but it seems much faster to implement.

Alfresco simple OCR. Extract text from PDF file and use it to start workflow

I'm using alfresco-simple-ocr with pdfsandwich and tesseract OCR. I want to get the text from a document inserted to a folder and then use the text and a pdf file in a new workflow. I've managed to do OCR extraction and how to start a workflow with a file inserted to catalogue,
but I can't get text from file and use it in the workflow. Is there a possibility to do this? Where can I start implementing that function ? Greetings, RafaƂ
You don't need any extension for that. Alfresco already integrates PDfBox that will do that for you. After, it depends of your PDF if it's a PDF containing images (so scanned documents) or if it's a PDF containing already text inside.
If you want to OCR some images, you have as well this module:
https://github.com/bchevallereau/alfresco-tesseract
When you know what you want to transform, you can look at this page where you have a javascript sample on how to call transformers:
http://docs.alfresco.com/5.2/references/dev-extension-points-content-transformer.html
You can do that as well in Java if you need.

How to run html with json files in SharePoint?

I am making SharePoint spaces for various departments in insurance company. One of them wants to save and share their outputs via SharePoint. That outputs are maps with risk areas. Because maps includes many data layers, all the files are in one folder.
I have uploaded a folder with CSS, JSON, JS and HTML files to the library in SharePoint, but when I doubleclicked on HTML file, the page will not load. I think it's due to the JSON files.
What I need is to run whole page correctly with simple doubleclick.
Can anyone give me advice how to run other files supporting HTML with doubleclicking on HTML file?
Thank you.
I've had this same issue. To get the HTML to play in the browser (without SharePoint trying to make you download it), you need to rename the HTML file to an ASPX file.
To do this, you need to be in the Windows Explorer view (from a document library, go Library > Open with Explorer). Then change the file name from index.html to index.aspx.
However, if you're also using JSON files, that could be an issue. SharePoint prohibits you from uploading JSON files unfortunately.

How do I download contents of an html table generated by play 1.2.7 backend on java in xls

I've generated a table using play's #{list} tag and get pretty decent results. Now I need to be able to generate and download an xls version of the table and have no idea what to do. Any pointers at all will be much appreciated
Well you have various options.
Excel will open HTML files. So instead of rendering your table as HTML you can it to stream it to the browser and set the content type as XLS.
While Excel will open it this it will still be an HTML file rather than an XLS(X) document.
You can generate as CSV from your data model and stream this to the browser. Again this will be a CSV rather than a proper XLS(X) document.
There also seem to be some solutions around which can do it using Javscript. See as a starting point: Generate excel sheet from html tables using jquery
Finally you can can use something like Apache POI or JXLS to generate a 'proper' xls(x) document and stream this to the browser. I have some code here that will export HTML to 'proper' xlsx file if this is the route you wish to go. Workflow is then to create some HTML from your data model and use this to convert to Excel rather than having to programmatically build the Excel document using POI. https://github.com/alanhay/html-exporter

Saving several images (and metadata for each) in a single file using Adobe Air

Is it possible, via Adobe Air, to save multiple types of data in a single file? For example, an application would allow the user to load in external images, position them on stage and label them. This data would be then be stored in a ByteArray (I guess) using BitmapData for the images and probably XML for the metadata.
I would then like to write this to a single file, with a bespoke file extension that could be associated with said Air app.
I've asked this on various forums and never received a single reply.
You can add everything to a byte array and write it to file - but defining boundaries and extracting individual entities back from the file would take some effort. How about writing them to normal files, zipping them to a single file and deleting the originals? This way you can still have a single file and deal with the individual items more easily.
This article describes some ActionScript zip libraries. I've used nochump in the past and it was easy - this page has some sample code
If you want some individuality for your files, you can rename the zipped file to whatever extension you want - that's what Firefox extensions do, they have .xpi extension, but they're plain zip files renamed.