Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Lesson 06 #96

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lesson-06-begin/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM manuth/silverstripe-dev
RUN curl -s https://getcomposer.org/installer | php
RUN mv composer.phar /usr/bin/composer
6 changes: 6 additions & 0 deletions Lesson-06-begin/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "SilverStripe Development",
"dockerComposeFile": "docker-compose.yml",
"service": "silverstripe",
"workspaceFolder": "/var/www/html"
}
27 changes: 27 additions & 0 deletions Lesson-06-begin/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3'

services:
silverstripe:
build:
context: .
dockerfile: Dockerfile
environment:
- SS_DATABASE_CHOOSE_NAME=true
- SS_DATABASE_CLASS=MySQLPDODatabase
- SS_DATABASE_SERVER=db
- SS_DATABASE_USERNAME=root
- SS_DATABASE_PASSWORD=root
- SS_ENVIRONMENT_TYPE=dev
- SS_DEFAULT_ADMIN_USERNAME=root
- SS_DEFAULT_ADMIN_PASSWORD=password
ports:
- 8888:80
volumes:
- ..:/var/www/html
db:
image: mysql:5
environment:
- MYSQL_ROOT_PASSWORD=root
volumes:
- ./mysql-data:/var/lib/mysql
- ./initdb.d:/docker-entrypoint-initdb.d

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Lesson-06-begin/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space

[*.{yml,json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
Expand Down
8 changes: 3 additions & 5 deletions Lesson-06-begin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/.env
/vendor/
/themes/simple/
/resources/
/public/resources/
/node_modules/


/_resources/
/public/_resources/
.devcontainer/mysql-data/
2 changes: 2 additions & 0 deletions Lesson-06-begin/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RewriteEngine On
RewriteRule ^(.*)$ public/$1
28 changes: 28 additions & 0 deletions Lesson-06-begin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Overview

Base project folder for a SilverStripe ([http://silverstripe.org](http://silverstripe.org)) installation. Required modules are installed via [http://github.com/silverstripe/recipe-cms](http://github.com/silverstripe/recipe-cms). For information on how to change the dependencies in a recipe, please have a look at [https://github.com/silverstripe/recipe-plugin](https://github.com/silverstripe/recipe-plugin). In addition, installer includes [theme/simple](https://github.com/silverstripe-themes/silverstripe-simple) as a default theme.

## Installation ##

See [installation on different platforms](http://doc.silverstripe.org/framework/en/installation/),
and [installation from source](http://doc.silverstripe.org/framework/en/installation/from-source).

## Bugtracker ##

Bugs are tracked on github.com ([framework issues](https://github.com/silverstripe/silverstripe-framework/issues),
[cms issues](https://github.com/silverstripe/silverstripe-cms/issues)).
Please read our [issue reporting guidelines](https://docs.silverstripe.org/en/4/contributing/issues_and_bugs/).

## Development and Contribution ##

If you would like to make changes to the SilverStripe core codebase, we have an extensive [guide to contributing code](http://doc.silverstripe.org/framework/en/misc/contributing/code).

## Links ##

* [Changelogs](http://doc.silverstripe.org/framework/en/changelogs/)
* [Bugtracker: Framework](https://github.com/silverstripe/silverstripe-framework/issues)
* [Bugtracker: CMS](https://github.com/silverstripe/silverstripe-cms/issues)
* [Bugtracker: Installer](https://github.com/silverstripe/silverstripe-installer/issues)
* [Forums](http://silverstripe.org/forums)
* [Developer Mailinglist](https://groups.google.com/forum/#!forum/silverstripe-dev)
* [License](./LICENSE)
8 changes: 8 additions & 0 deletions Lesson-06-begin/app/_config.php
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
<?php

use SilverStripe\Security\PasswordValidator;
use SilverStripe\Security\Member;

// remove PasswordValidator for SilverStripe 5.0
$validator = PasswordValidator::create();
// Settings are registered via Injector configuration - see passwords.yml in framework
Member::set_password_validator($validator);
1 change: 0 additions & 1 deletion Lesson-06-begin/app/_config/theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ SilverStripe\View\SSViewer:
themes:
- '$public'
- '$default'

23 changes: 0 additions & 23 deletions Lesson-06-begin/app/composer.json

This file was deleted.

8 changes: 4 additions & 4 deletions Lesson-06-begin/app/src/ArticleHolder.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use Page;

class ArticleHolder extends Page
{
private static $allowed_children = [
ArticlePage::class
];
private static $allowed_children = [
ArticlePage::class
];
}
2 changes: 1 addition & 1 deletion Lesson-06-begin/app/src/ArticleHolderController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use PageController;

Expand Down
4 changes: 2 additions & 2 deletions Lesson-06-begin/app/src/ArticlePage.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use Page;

class ArticlePage extends Page
{
private static $can_be_root = false;
private static $can_be_root = false;
}
2 changes: 1 addition & 1 deletion Lesson-06-begin/app/src/ArticlePageController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use PageController;

Expand Down
2 changes: 1 addition & 1 deletion Lesson-06-begin/app/src/HomePage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use Page;

Expand Down
2 changes: 1 addition & 1 deletion Lesson-06-begin/app/src/HomePageController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SilverStripe\Lessons;
namespace SilverStripe\Example;

use PageController;

Expand Down
15 changes: 8 additions & 7 deletions Lesson-06-begin/app/src/Page.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

use SilverStripe\CMS\Model\SiteTree;
namespace {

class Page extends SiteTree
{
private static $db = array(
);
use SilverStripe\CMS\Model\SiteTree;

private static $has_one = array(
);
class Page extends SiteTree
{
private static $db = [];

private static $has_one = [];
}
}
72 changes: 36 additions & 36 deletions Lesson-06-begin/app/src/PageController.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<?php

use SilverStripe\CMS\Controllers\ContentController;
namespace {

use SilverStripe\View\Requirements;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\View\Requirements;

class PageController extends ContentController
{
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
private static $allowed_actions = array(

);

protected function init()
class PageController extends ContentController
{
parent::init();
Requirements::css('css/bootstrap.min.css');
Requirements::css('css/style.css');
Requirements::javascript('javascript/common/modernizr.js');
Requirements::javascript('javascript/common/jquery-1.11.1.min.js');
Requirements::javascript('javascript/common/bootstrap.min.js');
Requirements::javascript('javascript/common/bootstrap-datepicker.js');
Requirements::javascript('javascript/common/chosen.min.js');
Requirements::javascript('javascript/common/bootstrap-checkbox.js');
Requirements::javascript('javascript/common/nice-scroll.js');
Requirements::javascript('javascript/common/jquery-browser.js');
Requirements::javascript('javascript/scripts.js');
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* [
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* ];
* </code>
*
* @var array
*/
private static $allowed_actions = [];

protected function init()
{
parent::init();
Requirements::themedCSS('css/bootstrap.min.css');
Requirements::themedCSS('css/style.css');
Requirements::themedJavascript('javascript/common/modernizr.js');
Requirements::themedJavascript('javascript/common/jquery-1.11.1.min.js');
Requirements::themedJavascript('javascript/common/bootstrap.min.js');
Requirements::themedJavascript('javascript/common/bootstrap-datepicker.js');
Requirements::themedJavascript('javascript/common/chosen.min.js');
Requirements::themedJavascript('javascript/common/bootstrap-checkbox.js');
Requirements::themedJavascript('javascript/common/nice-scroll.js');
Requirements::themedJavascript('javascript/common/jquery-browser.js');
Requirements::themedJavascript('javascript/scripts.js');
}
}
}
22 changes: 11 additions & 11 deletions Lesson-06-begin/app/templates/Includes/Banner.ss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="parallax colored-bg pattern-bg" data-stellar-background-ratio="0.5">
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1 class="page-title">$Title</h1>
<div class="breadcrumb">
$Breadcrumbs
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1 class="page-title">$Title</h1>
<div class="breadcrumb">
$Breadcrumbs
</div>
</div>
</div>
</div>
</div>
Loading