Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kamalptw/cad9cc02dc7d483aaa8f2e05ed2b8fc6 to your computer and use it in GitHub Desktop.
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..
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
@newaaz
Copy link

newaaz commented Nov 7, 2021

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);

@lksh2812
Copy link

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?

@kamalptw
Copy link
Author

@lksh2812 I think committing the precompiled assets in public/assets would work just fine. Hope this helps

@lksh2812
Copy link

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