Last active
March 1, 2023 09:01
-
-
Save kamalptw/cad9cc02dc7d483aaa8f2e05ed2b8fc6 to your computer and use it in GitHub Desktop.
If you have a Metronic theme and want to use it in rails or any other framework..
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
Copy tools to root of project | |
Copy src of your final selected demo to lib/src | |
Open tools/gulp.config.json | |
Paste this | |
{ | |
"config": { | |
"path": { | |
"src": "../lib/src" | |
}, | |
"dist": [ | |
"../public/assets" | |
] | |
} | |
} | |
Open tools/gulp.config.js | |
Inside config object, change path and dist to this | |
path: { | |
src: "../lib/src", | |
common_src: "../lib/src", | |
node_modules: "node_modules", | |
}, | |
dist: ["../public/assets"], | |
Go to tools directory | |
npm install --global npm@latest | |
npm install --global yarn | |
npm install --global gulp-cli | |
npm rm --global gulp | |
gulp --version | |
yarn | |
gulp | |
gulp watch | |
Now your assets are being built to public/assets | |
All js/css changes need to be made to lib/src | |
With watcher running via gulp watch, any new changes will be immediately ported to public/assets | |
To override styles use the file lib/src/sass/components/_variables.custom.scss | |
For Generated layout partials | |
Create your layout using https://preview.keenthemes.com/metronic8/demo1/layout-builder.html | |
Put the contents of the generated layout and partials in the app/views/ directory | |
Go to app/views/layout and in your terminal execute the shell commands below | |
for file in */*/*/*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in */*/*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in */*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in *.html; do mv "$file" "${file/.html/.html.erb}"; done | |
Go to app/views/partials and in your terminal execute the shell commands below | |
for file in */*/*/*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in */*/*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in */*.html; do mv "$file" "${file/.html/.html.erb}"; done | |
for file in *.html; do mv "$file" "${file/.html/.html.erb}"; done | |
In app/views directory do CMD+SHIFT+F (Find in folder) | |
Find & replace <!--layout-partial: to <%= render ' | |
Find & replace .html--> to ' %> | |
Find & replace /_ to / | |
index.html is moved to application.html.erb as its the root layout | |
master.html is changed to _master.html.erb |
Hi, This is really useful. But how did you compiled assets at time of deployment? Did you commit the precompiled assets in public/assets or is there any other way?
@lksh2812 I think committing the precompiled assets in public/assets would work just fine. Hope this helps
Ok, I was worrying as generally, it is ignored in VCS. Also, did you include the entire theme or selected assets? It is a big theme.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thancs! What did you do with Turbo or Tubolinks? I connected manually SCSS and JS files in app/javascript and all works. But when following the links many components don't work. Now I'm trying to solve this problem
UPD:
just in all components replace
document.addEventListener('DOMContentLoaded', KTT function_name.init);
to
document.addEventListener('turbolinks:load', KTT function_name.init);