Last active
December 23, 2015 04:29
-
-
Save thomseddon/6580866 to your computer and use it in GitHub Desktop.
Reformat cakephp templates (generated with bake) to bootstrap style using sed
This file contains hidden or 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
# Remove "actions" divs | |
find View/ -name "*.ctp" -exec sed -i ':a;N;$!ba;s/<div class="actions">\(.*\)<\/div>//g' '{}' \; | |
# Add "table" class to tables | |
find View/ -name "*.ctp" -exec sed -i "s/<table\(.*\)/<table class=\"table table-striped\">/g" '{}' \; | |
# Add btn classes to buttons | |
find View/ -name "*.ctp" -exec sed -i "s/view\(.*\))/view\1, array('class' => 'btn btn-default'))/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/edit\(.*\))/edit\1, array('class' => 'btn btn-info'))/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/delete\(.*\), null/delete\1, array('class' => 'btn btn-danger')/g" '{}' \; | |
# Wrap created/modified with custom date formatter function ("df") | |
find View/ -name "*.ctp" -exec sed -i "s/h(\(.*\)\(created\|modified\)'])/df(\1\2'])/g" '{}' \; | |
# Format pagination links | |
find View/ -name "*.ctp" -exec sed -i "s/div class=\"paging\"/ul class=\"pagination\"/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/Paginator->prev(\(.*\)/Paginator->prev('\«', array('tag' => 'li', 'escape' => false), '<a href=\"#\">\«<\/a>', array('class' => 'prev disabled', 'tag' => 'li', 'escape' => false));/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/Paginator->numbers(\(.*\)/Paginator->numbers(array('separator' => '', 'tag' => 'li', 'currentLink' => true, 'currentClass' => 'active'));/g" '{}' \; | |
find View/ -name "*.ctp" -exec sed -i "s/Paginator->next(\(.*\)/Paginator->next('\»', array('tag' => 'li', 'escape' => false), '<a href=\"#\">\»<\/a>', array('class' => 'prev disabled', 'tag' => 'li', 'escape' => false));/g" '{}' \; | |
# Format form submits | |
find View/ -name *.ctp -exec sed -i "s/Form->end(__('Submit'))/Form->end(array('value' => __('Submit'), 'class' => 'btn btn-default', 'before' => '<div class="col-md-2"><\/div>'))/g" '{}' \; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment