Starting Theme structure with Bootstrap, composer and compiling the project.

This commit is contained in:
Fabiano Alencar 2018-01-24 17:09:23 -02:00
parent 6478d45d28
commit 324adb9155
8 changed files with 147 additions and 11 deletions

5
.gitignore vendored
View File

@ -1,4 +1,7 @@
build-config.cfg
composer.lock
src/style.css
src/style.css.map
src/scss/.sass-cache
src/scss/.sass-cache/
src/vendor/
vendor/

View File

@ -2,14 +2,23 @@
source build-config.cfg
## Install composer dependencies
composer install
## Compile SASS
sh compile-sass.sh
## Install composer dependencies
## composer install
echo "Updating files in $destination"
echo "Updating files of theme"
rm -rf $destination
mkdir $destination
cp -R src/* $destination/
##Removendo o arquivo sass
rm -rf $destination/scss
##Bootstrap
mkdir $destination/vendor/bootstrap/css
cp $destination/vendor/bootstrap/scss/bootstrap.min.css $destination/vendor/bootstrap/css
rm -rf $destination/vendor/bootstrap/scss
echo "Finish!!"

19
compile-sass.sh Normal file → Executable file
View File

@ -2,15 +2,22 @@
# Executa o comando 'sass' para verificar se existe (veja http://stackoverflow.com/a/677212/329911)
command -v sass >/dev/null 2>&1 || {
echo >&2 "SASS parece não está disponivel.";
echo >&2 "SASS does not seem to be available.";
exit 1;
}
# Define o caminho.
echo "Compilando Sass..."
cd src/scss
sass -E 'UTF-8' style.scss:../style.css
echo "Compiling Sass..."
echo "Compilação do Sass Concluído!"
#Bootstrap
cd src/vendor/bootstrap/scss
sass bootstrap.scss:bootstrap.min.css --style compressed
#Style do Tema
cd ../../../scss
sass -E 'UTF-8' style.scss:../style.css
cd ..
rm -rf style.css.map
echo "Sass compilation Completed!"
exit 0

15
composer.json Normal file
View File

@ -0,0 +1,15 @@
{
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org"
}
],
"require": {
"twbs/bootstrap": "4.0.0"
},
"scripts": {
"post-install-cmd": "bash install.sh",
"post-update-cmd": "bash install.sh"
}
}

42
install.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/bash
php -r '
echo "\n ..::Tainacan Theme::..\n";
echo "\nStarting installation with composer ... please wait!!";
echo "\nChecking if project folders exist ...\n\n";
if (!file_exists("vendor/bootstrap")) {
mkdir("src/vendor/bootstrap/", 0777, true);
mkdir("src/vendor/bootstrap/scss", 0777, true);
mkdir("src/vendor/bootstrap/js", 0777, true);
}
echo "\nVerification completed...\n";
echo "\nStarting Copying Files...\n";
echo "...Bootstrap\n";
if (!file_exists("src/vendor/bootstrap/scss/bootstrap.scss")) {
recurse_copy("vendor/twbs/bootstrap/scss", "src/vendor/bootstrap/scss");
copy("vendor/twbs/bootstrap/dist/js/bootstrap.min.js", "src/vendor/bootstrap/js/bootstrap.min.js");
}
echo "Finish!\n\n";
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != "." ) && ( $file != ".." )) {
if ( is_dir($src . "/" . $file) ) {
recurse_copy($src . "/" . $file,$dst . "/" . $file);
}
else {
copy($src . "/" . $file,$dst . "/" . $file);
}
}
}
closedir($dir);
}
'

41
src/functions.php Normal file
View File

@ -0,0 +1,41 @@
<?php
if(!function_exists('tainacan_setup')) {
/**
* Execulta apos o tema ser inicializado.
* Isso é usado para a configuração básica do tema, registro dos recursos do tema e init hooks.
* Observe que esta função está conectada ao gancho after_setup_theme, que é executado antes do gancho de init.
*/
function tainacan_setup() {
/**
* Não exibe o menu do administrador na pagina do site. Mesmo quando estiver logado!
**/
show_admin_bar( false );
/**
* Desabilita o FTP na instalação de Plugins
*/
define('FS_METHOD', 'direct');
}
}
add_action( 'after_setup_theme', 'tainacan_setup' );
/**
* Inclui os scripts javascript necessários ao front do thema
*/
function tainacanEnqueueScripts(){
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/vendor/bootstrap/js/bootstrap.min.js', array('jquery'), '4.0.0', true);
}
add_action('wp_enqueue_scripts', 'tainacanEnqueueScripts');
/**
* Inclui os styles necessários ao front do thema
*/
function tainacanEnqueueStyles(){
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/vendor/bootstrap/scss/bootstrap.min.css');
wp_enqueue_style('style', get_stylesheet_uri(), array('bootstrap'));
}
add_action('wp_enqueue_scripts', 'tainacanEnqueueStyles');

7
src/index.php Normal file
View File

@ -0,0 +1,7 @@
<?php
//Header
get_header();
//Footer
get_footer();

View File

@ -0,0 +1,12 @@
/*
Theme Name: Tainacan
Theme URI: https://github.com/tainacan/tainacan-theme
Author: MediaLab UFG
Author URI: https://github.com/medialab-ufg/
Description: Tema desenvolvido para o Tainacan
Version: 1.0
License: GNU Affero General Public License v3
License URI:https://www.gnu.org/licenses/agpl-3.0.en.html
Tags: tainacan, ufg, minc, cultura, flexible, open_source
Text Domain: tainacan
*/