Last active
December 20, 2015 11:59
-
-
Save astockwell/6127640 to your computer and use it in GitHub Desktop.
Creates a working project for flat (non-Wordpress) site development from the latest [KLAS framework](https://github.com/kylelarkin/klas). Usage is indicated at the top of the file. Don't use if you don't understand what's going on, as this file is destructive. Remove from your project after use.
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
#!/bin/bash | |
#### TO USE #### | |
# 1. Create a new folder for your project | |
# 2. Save this script in that folder (as klas_to_flat.sh) | |
# 3. Run `chmod +x klas_to_flat.sh` to make it executable | |
# 4. Run `./klas_to_flat.sh` | |
#### Smile #### | |
set -eu | |
git clone https://github.com/kylelarkin/klas.git | |
cd klas/ | |
rm -rf .git 404.php archive.php comments.php functions.php index.php readme.md screenshot.png searchform.php sidebar.php single.php style.css wp-config.php css/editor-style.css sass/editor-style.scss | |
cat header.php >> index.html && printf "\n" >> index.html && cat page.php >> index.html && printf "\n" >> index.html && cat footer.php >> index.html | |
rm -rf header.php page.php footer.php | |
sed -i '' 's/<?php language_attributes(); ?>/dir="ltr" lang="en-US"/g' index.html | |
sed -i '' "s/<?php bloginfo( 'charset' ); ?>/UTF-8/g" index.html | |
sed -i '' "s/<?php bloginfo('name'); ?><?php wp_title('|'); ?>//g" index.html | |
sed -E -i '' '/\<\?php wp_head\(\); \?\>/{N;d;}' index.html | |
sed -E -i '' "s/(\<\?php bloginfo\( 'stylesheet_directory' \); \?\>\/)|(\<\?php bloginfo\( 'template_directory' \)\; \?\>\/)//g" index.html | |
sed -i '' '/atom_url/d' index.html | |
sed -i '' '/favicon/d' index.html | |
sed -i '' "s/ <?php body_class(); ?>//g" index.html | |
sed -n ' | |
/var site_url/{n | |
n | |
x | |
d | |
} | |
x | |
1d | |
p | |
${x | |
p | |
} | |
' index.html > index.html~ | |
mv index.html~ index.html | |
sed -E -i '' 's/\<\?php wp_nav_menu(.*)\?\>//g' index.html | |
sed -E -i '' 's/ \<\!-- End Header --\>//g' index.html | |
sed -E -i '' '/^\t?\<\?php get(.*)[?-]\>$/d' index.html | |
sed -E -i '' '/\<\?php (if|end)/d' index.html | |
sed -E -i '' 's/\<\?php the_(.*)\(\); \?\>//g' index.html | |
sed -E -i '' '/get_sidebar/d' index.html | |
sed -E -i '' 's/.*\©.*//g' index.html | |
sed -E -i '' '/wp_footer/d' index.html | |
sed -E -i '' 's/^\<\?php wp_enqueue_script(.*)\?\>$/\<script src="js\/script-min\.js"\>\<\/script\>/g' index.html | |
sed -i '' '/script-min/i \ | |
\<script src\="http:\/\/ajax\.googleapis\.com\/ajax\/libs\/jquery\/1\.9\.1\/jquery\.min\.js"\>\<\/script\> \ | |
' index.html | |
sed -E -i '' 's|/wp-content/themes/klas/||g' sass/ie.scss css/ie.css | |
cd .. | |
mv klas/* . | |
mv klas/.htaccess klas/.gitignore . | |
rm -rf klas/ | |
git init | |
git add . | |
git commit -am 'initial commit' | |
git status | |
echo "Your flat project is ready!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment