forked from hi-primus/optimus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close hi-primus#599 : External CSS to Inline CSS
- Loading branch information
Showing
10 changed files
with
840 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,7 @@ readme/data/foo\.json/ | |
readme/data/foo\.parquet/ | ||
|
||
readme/data/foo\.csv/ | ||
|
||
#nodeJS | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,64 @@ | ||
# Hacking Optimus | ||
|
||
##Windows | ||
##Windows | ||
|
||
If you want to contribute, hack or play with Optimus you are in the raight place. This is a little guide to | ||
If you want to contribute, hack or play with Optimus you are in the raight place. This is a little guide to | ||
|
||
* Install Jupyter Notebooks | ||
- Install Jupyter Notebooks | ||
|
||
Download anaconda from https://www.anaconda.com/download/ and run the file | ||
|
||
* Clone the Repo and install requirements | ||
- Clone the Repo and install requirements | ||
|
||
Go to the folder you want to download de repo and run: | ||
|
||
`git clone https://github.com/ironmussa/Optimus.git` | ||
`git clone https://github.com/ironmussa/Optimus.git` | ||
|
||
The install the requirements | ||
|
||
`pip install -r requirements.txt` | ||
|
||
* Install Spark | ||
- Install Spark | ||
|
||
Go to http://spark.apache.org/downloads.html and download Spark 2.3.1 with Pre-built Hadoop 2.7 | ||
Decompress the file in c:\opt\spark | ||
|
||
* Install java | ||
- Install java | ||
|
||
First, install chocolatey https://chocolatey.org/install#installing-chocolatey | ||
>> Chocolatey needs Administrative permission. | ||
|
||
> > Chocolatey needs Administrative permission. | ||
Then from the command line | ||
`choco install jdk8` | ||
|
||
## Set vars | ||
|
||
Be sure that the Spark version is the same that you download | ||
|
||
`setx SPARK_HOME C:\opt\spark\spark-2.3.1-bin-hadoop2.7` | ||
|
||
Check in the console if python is run as 'python','python3' etc. Use the one you found to set PYSPARK_PYTHON | ||
`setx PYSPARK_PYTHON python` | ||
|
||
Open the examples folder in the cloned Optimus repo and go to hack_optimus.ipyn. There you are going fo find some tips | ||
Open the examples folder in the cloned Optimus repo and go to hack_optimus.ipyn. There you are going fo find some tips | ||
to hack and contribute with Optimus | ||
|
||
## Troubleshooting | ||
|
||
Error: you do not have permission to tmp\hive | ||
from anaconda | ||
from anaconda | ||
wintools.exe ls c:\tmp\hive | ||
wintools.exe chmod 777 c:\tmp\hive | ||
|
||
## Processing CSS | ||
|
||
To add and external CSS file to the templates html as inline CSS | ||
|
||
- Install NodeJS | ||
|
||
Go to https://nodejs.org and download and install Node JS | ||
|
||
- Run `npm install` | ||
|
||
- Run `node inlinecss.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var fs = require('fs'); | ||
var juice = require('juice'); | ||
|
||
/*CSS*/ | ||
var sourceCss = fs.readFileSync('optimus/css/styles.css', 'utf-8'); | ||
|
||
/*HTML to READ*/ | ||
var oneColumn = fs.readFileSync( | ||
'optimus/profiler/templates/one_column.html', | ||
'utf-8', | ||
); | ||
var generalInfo = fs.readFileSync( | ||
'optimus/profiler/templates/general_info.html', | ||
'utf-8', | ||
); | ||
var table = fs.readFileSync('optimus/templates/table.html', 'utf-8'); | ||
|
||
/** ADD STYLE TAG & CONCAT TO THE FILE */ | ||
var inlineCssOneColumn = juice('<style>' + sourceCss + '</style>' + oneColumn, { | ||
removeStyleTags: true, | ||
preserveMediaQueries: true, | ||
}); | ||
var inlineCssGeneralInfo = juice( | ||
'<style>' + sourceCss + '</style>' + generalInfo, | ||
{ removeStyleTags: true, preserveMediaQueries: true }, | ||
); | ||
var inlineCssTable = juice('<style>' + sourceCss + '</style>' + table, { | ||
removeStyleTags: true, | ||
preserveMediaQueries: true, | ||
}); | ||
|
||
/** CREATE A INLINE-CSS HTML FILE */ | ||
fs.writeFile( | ||
'optimus/profiler/templates/build/one_column.html', | ||
inlineCssOneColumn, | ||
function(err) { | ||
if (err) throw err; | ||
console.log( | ||
'File is created successfully in "optimus/profiler/templates/build/one_column.html"', | ||
); | ||
}, | ||
); | ||
|
||
fs.writeFile( | ||
'optimus/profiler/templates/build/general_info.html', | ||
inlineCssGeneralInfo, | ||
function(err) { | ||
if (err) throw err; | ||
console.log( | ||
'File is created successfully in "optimus/profiler/templates/build/general_info.html"', | ||
); | ||
}, | ||
); | ||
|
||
fs.writeFile('optimus/templates/build/table.html', inlineCssTable, function( | ||
err, | ||
) { | ||
if (err) throw err; | ||
console.log( | ||
'File is created successfully in "optimus/templates/build/table.html"', | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.