From 4edee9a818073a1db46510ece0253a89f8c18970 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 2 Sep 2018 16:34:14 -0500 Subject: [PATCH 1/5] Added github pages deployment setup to travis --- .travis.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.travis.yml b/.travis.yml index 512d222..05421d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,31 @@ language: php php: - '7.1' +branches: + only: + - master + cache: directories: - $HOME/.composer/cache + - $HOME/.npm + +before_install: + - nvm install 8 install: - composer update --prefer-dist --no-interaction --prefer-stable --no-suggest + - npm update script: + - php apprentice build + - npm run prod - vendor/bin/phpunit + +deploy: + provider: pages + skip-cleanup: true + local-dir: .build + target-branch: gh-pages + on: + branch: master From fee7b398efa1f675a49e76b954a9b76c6a8ab9f6 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 2 Sep 2018 16:34:46 -0500 Subject: [PATCH 2/5] Tweaked css for home grid and chrome button outline --- assets/css/site.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/css/site.css b/assets/css/site.css index fca5648..b59d48b 100644 --- a/assets/css/site.css +++ b/assets/css/site.css @@ -56,6 +56,9 @@ button { button:hover { color: $primary-color-dark; } +button:focus { + outline: 0; +} button .icon { vertical-align: middle; } @@ -124,7 +127,7 @@ button:hover .icon svg { .grid-toc { display: grid; grid-template-columns: 2fr 1fr; - grid-column-gap: 3em; + grid-column-gap: 1em; } .navigate-links { margin: 1em 0; From 7580f989281187dd121b95deee4aa8438effafda Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 2 Sep 2018 16:46:49 -0500 Subject: [PATCH 3/5] Added 404 page --- assets/css/site.css | 19 +++++++++++++++++++ assets/templates/404.phtml | 11 +++++++++++ config.php | 1 + 3 files changed, 31 insertions(+) create mode 100644 assets/templates/404.phtml diff --git a/assets/css/site.css b/assets/css/site.css index b59d48b..18ac72d 100644 --- a/assets/css/site.css +++ b/assets/css/site.css @@ -218,3 +218,22 @@ button:hover .icon svg { from {left: -300px; opacity: 0} to {left: 0; opacity: 1} } +.logo-404 { + max-width: 200px; + max-height: 200px; + margin: 0 auto; + display: block; +} +.logo-404 svg { + max-width: 200px; + max-height: 200px; +} +.toc-404 { + max-width: 250px; + margin: 0 auto; +} +.message-404 { + font-size: 2em; + margin: 0 auto; + text-align: center; +} diff --git a/assets/templates/404.phtml b/assets/templates/404.phtml new file mode 100644 index 0000000..737b62d --- /dev/null +++ b/assets/templates/404.phtml @@ -0,0 +1,11 @@ + 'PHP Apprentice']) ?> + +
+ +

Whoops! The page could not be found.

+
+ +
+
+ + diff --git a/config.php b/config.php index a71f8d7..b77d917 100644 --- a/config.php +++ b/config.php @@ -10,6 +10,7 @@ return [ 'pages' => [ Page::create('index', 'index.phtml'), Page::create('credits', 'credits.phtml'), + Page::create('404', '404.phtml'), Page::create('basics', null, 'basics.php', [ 'title' => 'Basics', 'subtitle' => 'Getting started', From f36bb1f1956682c7f3c50b552d6f3af4da7fe066 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 2 Sep 2018 17:16:37 -0500 Subject: [PATCH 4/5] Wrote inital content for classes-visibility and tweaked classes page --- code/classes-visibility.php | 43 +++++++++++++++++++++++++++++++++++++ code/classes.php | 8 ++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/code/classes-visibility.php b/code/classes-visibility.php index e69de29..24e1d90 100644 --- a/code/classes-visibility.php +++ b/code/classes-visibility.php @@ -0,0 +1,43 @@ +number = $number; + } +} + +// We cannot set the number using "$phone->number = '123-456-7890'". +// Instead, we can use the public method. +$phone = new Phone(); +$phone->setNumber('123-456-7890'); + +// Making an attribute or function private, gives you more control over the data in the object. +// For example, we could prevent a number being set if it starts with a 7. +class Phone2 +{ + private $number; + + public function setNumber($number) + { + if (substr($number, 0, 1) !== '7') { + $this->number = $number; + } + } +} + +// The "protected" and "private" keywords work a little differently, but we +// will learn more about "protected" when we discuss inheritance. +// However, they both prevent functions and properties from being accessed outside an object. +class Phone3 +{ + private $number; + protected $caller; +} diff --git a/code/classes.php b/code/classes.php index f568ce5..c3e6a19 100644 --- a/code/classes.php +++ b/code/classes.php @@ -24,9 +24,15 @@ $bike = new Bicycle(); $bike->color = 'Blue'; echo $bike->color . "\n"; +// An instance of a class is called an object. Congratulations! +// You are now performing object-oriented development. +$redBike = new Bicycle(); +$redBike->color = 'Red'; +echo $redBike->color . " Bike Object\n"; + // A method is a function attached to the class. You can add a method // to a class by using the "public" keyword followed by the function. A method -// can access the attributes and methods of the instance using the "$this" variable. +// can access the attributes and methods of an object instance using the "$this" variable. class Tricycle { public $color; From 0ce42087cfe89d7752358cd43640e7f86533bca0 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 2 Sep 2018 17:21:34 -0500 Subject: [PATCH 5/5] Fixed bug in build script that auto creates build directory --- src/Build.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Build.php b/src/Build.php index efe3fcb..50b8d5e 100644 --- a/src/Build.php +++ b/src/Build.php @@ -76,6 +76,10 @@ class Build } $output = $this->getOutput($template, $page->variables); + if (!file_exists(config('output_dir'))) { + mkdir(config('output_dir')); + } + file_put_contents(config('output_dir') . '/' . $page->name . '.html', $output); return $output;