Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Support for Excel templatization #403

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

frisch-raphael
Copy link
Contributor

This pull request does the following :

Break the dabatase
Adding this code will break the database, as it changes some key elements and variable names. I suppose it is possible to manually edit your database file (master.db) in ordrer to keep your current database, but I didn't try to do it myself.

Add support for Excel templatization
The fonctionnality in itself
The main functionnality added by this PR, which mean there's now two kind of objects in the database : DocxXslts, and ExcelXslts.
The meta language is the same for both. Every character is supported but the screenshot ones. Metamarkup isn't supported.
The æ metachar is used to repeat the whole row it is on.
A new template file has been added (avaialable at "./templates/Summary Generic.xslx". It's an excel file that provides examples on how to use Serpico's metalanguage for Excel. Feel free to add graphics or template for different scoring types.
How it is implemented
Instead of regexing my way through the meta characters, I used nokogiri and xpathes. This makes the Excel metalanguage more stable, as I feel subtle changes to the Excel XML structure will have less chances to impact the metalanguage fonctionnalities. It also adds possibilities, such as giving the user the exact cell in which there's an error of metachar pairing. I also think it makes the code a bit more understandable, xpath being just a tad bit less tedious to understand than regexes.
I had to modify a LOT of things to make this work with the SerpicoProject master. I hope I didn't break anything in the process.
Moreover, the code was tested for Excel 2016. It would be nice to test this functionnality for other version of Excel.

Centralizes the xslt generation code
All template types (status template, report templates, excel templates, finding template), are now managed by the same route : /report/:id/generate/:template_type.
This was done so that changes in the way xslt is produced doesn't have to be repeated for each generation code part.
EDIT : I can already see that I didn't add this properly. I'll check this when I have time.

homogenizes the code and respect ruby's best practices
The modified files should now respect ruby's best practices from https://github.com/bbatsov/ruby-style-guide
That's the reason the number of line added/removed is so massive.

Rename some functions name
Some functions name were misleading. I Changed them so that they describe what the do most closely

What's the next step ?
When I have time I'd like to add support for powerpoint. This shouldn't be too soon though. I also have quite a few pull request that I didn't have time to make (this one took quite a lot of time).

@BuffaloWill
Copy link
Contributor

@frisch-raphael thanks for another cool submission. Plugins can support a second database and a modified model for the data. We might be able to move this PR into a plugin and get it landed.

On a different note, how difficult would it be to submit some of the Ruby standards compliance code in a different PR? Even better would be a script I could run on my side.

@frisch-raphael
Copy link
Contributor Author

I can tell you how I did :

Open the project with atom : https://atom.io/
Install rubocop : https://github.com/bbatsov/rubocop
Install the atom-beautify plugin : https://github.com/Glavin001/atom-beautify
Press Ctrl-Alt-B on every file you want to beautify => Rubocop will edit the file

Let me know if you have trouble with this, I could always do a quick PR

@frisch-raphael
Copy link
Contributor Author

Would you considerer adding this PR if I managed to modify the code in a way that wouldn't break the database anymore, or are you set on this being a plugin ?
I feel the first option would make fixing the code easier for me.

@mfr-itr
Copy link

mfr-itr commented Jun 15, 2018

Do you plan on finishing this feature? It would be really useful for us.

@frisch-raphael
Copy link
Contributor Author

I'll try to make a plugin out of this PR when I have some time

@mfr-itr
Copy link

mfr-itr commented Aug 7, 2018

Hi! By any chance, did you find some time to look at it?

@frisch-raphael
Copy link
Contributor Author

The plugin is pretty much ready. It's just a matter of finding time to make the pull request.

@Demaz93
Copy link

Demaz93 commented Jan 11, 2019

Hi, any news for this plugin?

@k0z4c
Copy link

k0z4c commented Mar 19, 2019

Hi!
This plugin can help me so much; what about? some news?
Thank you in advance

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants