Skip to content

Commit

Permalink
continuous improvement setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Aug 2, 2016
1 parent 081c05e commit 6d1f253
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 183 deletions.
30 changes: 24 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
# For more information about the properties used in this file,
# please see the EditorConfig documentation:
# http://editorconfig.org
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yml,package.json}]
# Docs say 80 ideally, 100 ok, no more than 120
# http://doc.silverstripe.org/en/getting_started/coding_conventions/
max_line_length = 100

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space

# The indent size used in the package.json file cannot be changed:
#PSR 2
[**.php]
indent_style = space
indent_size = 4

[{.travis.yml,package.json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2
indent_style = space
10 changes: 5 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/tests export-ignore
/docs export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml export-ignore
/tests export-ignore
/docs export-ignore
/.travis.yml export-ignore
/.scrutinizer.yml export-ignore
/phpunit.xml export-ignore
26 changes: 26 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
inherit: true

#Copied from https://www.adayinthelifeof.nl/2013/11/20/external-code-coverage-with-travis-scrutinizer/
tools:
external_code_coverage:
timeout: 600
php_code_sniffer:
config:
standard: PSR2
php_cs_fixer:
extensions:
# Default:
- php
fixers: []
enabled: false
filter:
paths: [tests/*,code/*]
excluded_paths: []
coding_style:
php:
indentation:
general:
use_tabs: false

filter:
paths: [tests/*,code/*]
58 changes: 58 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

language: php

sudo: false

addons:
apt:
packages:
- tidy

php:
- 7.0

before_install:
- pip install --user codecov

env:
global:
- DB=MYSQL CORE_RELEASE=3.4
- MODULE_PATH=imageuploadfield
- COVERAGE=0

matrix:
include:
- php: 5.6
env: DB=MYSQL COVERAGE=1
- php: 5.6
env: DB=PGSQL
- php: 5.6
env: DB=SQLITE
- php: hhvm
env: DB=MYSQL
allow_failures:
- php: 5.6
env: DB=MYSQL CORE_RELEASE=4.0
- php: 7.0
env: DB=MYSQL CORE_RELEASE=4.0

before_script:
- phpenv rehash
- composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss

script:
# Execute tests with no coverage. This is the fastest option
- "if [ \"$COVERAGE\" = \"0\" ]; then vendor/bin/phpunit $MODULE_PATH/tests/; fi"

# Execute tests with coverage. Do this for a small
- "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.clover $MODULE_PATH/tests/; fi"

after_script:
- "if [ \"$COVERAGE\" = \"1\" ]; then mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/; fi"
- cd ~/build/$TRAVIS_REPO_SLUG
- wget https://scrutinizer-ci.com/ocular.phar
- "if [ \"$COVERAGE\" = \"1\" ]; then travis_retry codecov && travis_retry php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi"

25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# ImageUploadField
# SilverStripe ImageUploadField
[![Build Status](https://travis-ci.org/dynamic/silverstripe-imageuploadfield.svg?branch=master)](https://travis-ci.org/dynamic/silverstripe-imageuploadfield)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/badges/build.png?b=master)](https://scrutinizer-ci.com/g/dynamic/silverstripe-imageuploadfield/build-status/master)
[![codecov](https://codecov.io/gh/dynamic/silverstripe-imageuploadfield/branch/master/graph/badge.svg?token=NwnVzhOZlx)](https://codecov.io/gh/dynamic/silverstripe-imageuploadfield)
[![Dependency Status](https://www.versioneye.com/user/projects/57a119373d8eb6004d77429c/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57a119373d8eb6004d77429c)

UploadField preconfigured for Image uploads. Allows max file size to be set
SilverStripe UploadField pre-configured for Image uploads. Allows max file size to be set site wide.

## Requirements

- SilverStripe 3.2

## Installation

This is how you install ImageUploadField.
composer require dynamic/silverstripe-imageuploadfield

## Example usage

You use ImageUploadField like this.
$imageField = ImageUploadField::create('Image', 'Image');

What it does:

* sets `AllowedMaxFileNumber` to 1
* sets `AllowedFileCategories` to `Image
* sets `AllowedMaxFileSize` to 1 MB

You can overwrite the `AllowedMaxFileSize` value in config.yml:

ImageUploadField:
max_upload: 512000

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
Name: ImageUploadFieldconfig
---
---
11 changes: 10 additions & 1 deletion code/ImageUploadField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

class ImageUploadField extends UploadField
{
/**
* @var int
*/
private static $max_upload = 1024000;

/**
* ImageUploadField constructor.
* @param string $name
* @param null $title
* @param SS_List|null $items
*/
public function __construct($name, $title = null, SS_List $items = null)
{
parent::__construct($name, $title);
Expand All @@ -17,4 +26,4 @@ public function __construct($name, $title = null, SS_List $items = null)
$this->setAllowedMaxFileNumber(1);
$this->setAllowedFileCategories('image');
}
}
}
21 changes: 8 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
{
"name": "ImageUploadField",
"description": "UploadField preconfigured for Image uploads. Allows max file size to be set",
"name": "dynamic/imageuploadfield",
"description": "SilverStripe UploadField pre-configured for Image uploads. Allows max file size to be set site wide.",
"authors": [
{
"name": "Dynamic, Inc.",
"email": "dev@dy.ag"
}
],
"keywords": [
"silverstripe"
"silverstripe", "dynamic", "image", "upload", "field", "module"
],
"type": "silverstripe-module",
"license": "BSD-3-Clause",
"require": {
"silverstripe/cms": "^3.2",
"silverstripe/framework": "^3.2",
"silverstripe/reactjs-common": "dev-master"
"silverstripe/framework": "^3.2"
},
"require-dev": {
"phpunit/PHPUnit": "^3.7"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/open-sausages/silverstripe-reactjs-common"
}
],
"config": {
"process-timeout": 600
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"extra": {
"installer-name": "imageuploadfield"
}
}
41 changes: 0 additions & 41 deletions gulpfile.js

This file was deleted.

7 changes: 0 additions & 7 deletions javascript/lang/en.js

This file was deleted.

3 changes: 0 additions & 3 deletions javascript/lang/src/en.js

This file was deleted.

15 changes: 0 additions & 15 deletions javascript/src/example-component.js

This file was deleted.

16 changes: 0 additions & 16 deletions javascript/src/main.js

This file was deleted.

42 changes: 0 additions & 42 deletions package.json

This file was deleted.

Empty file removed scss/main.scss
Empty file.
10 changes: 10 additions & 0 deletions tests/ImageUploadFieldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

class ImageUploadFieldTest extends SapphireTest
{
public function test__construct()
{
$field = new ImageUploadField('Image');
$this->assertInstanceOf('UploadField', $field);
}
}
Loading

0 comments on commit 6d1f253

Please sign in to comment.