Skip to content

Commit

Permalink
Merge pull request #24 from bummzack/pulls/ss4
Browse files Browse the repository at this point in the history
SS4 Upgrade.
  • Loading branch information
Damian Mooyman authored Feb 28, 2018
2 parents b2efdb2 + 2664068 commit 8f0c9e0
Show file tree
Hide file tree
Showing 93 changed files with 1,371 additions and 777 deletions.
16 changes: 10 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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/

[*]
charset = utf-8
Expand All @@ -10,8 +10,12 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.yml,package.json}]
[*.md]
trim_trailing_whitespace = false

[*.{yml,js,json,css,scss,eslintrc,feature}]
indent_size = 2
indent_style = space

# The indent size used in the package.json file cannot be changed:
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
[composer.json]
indent_size = 4
70 changes: 8 additions & 62 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,15 @@
inherit: true

build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]

checks:
php:
verify_property_names: true
verify_argument_usable_as_reference: true
verify_access_scope_valid: true
useless_calls: true
use_statement_alias_conflict: true
variable_existence: true
unused_variables: true
unused_properties: true
unused_parameters: true
unused_methods: true
unreachable_code: true
too_many_arguments: true
sql_injection_vulnerabilities: true
simplify_boolean_return: true
side_effects_or_types: true
security_vulnerabilities: true
return_doc_comments: true
return_doc_comment_if_not_inferrable: true
require_scope_for_properties: true
require_scope_for_methods: true
require_php_tag_first: true
psr2_switch_declaration: true
psr2_class_declaration: true
property_assignments: true
prefer_while_loop_over_for_loop: true
precedence_mistakes: true
precedence_in_conditions: true
phpunit_assertions: true
php5_style_constructor: true
parse_doc_comments: true
parameter_non_unique: true
parameter_doc_comments: true
param_doc_comment_if_not_inferrable: true
optional_parameters_at_the_end: true
one_class_per_file: true
no_unnecessary_if: true
no_trailing_whitespace: true
no_property_on_interface: true
no_non_implemented_abstract_methods: true
no_error_suppression: true
no_duplicate_arguments: true
no_commented_out_code: true
newline_at_end_of_file: true
missing_arguments: true
method_calls_on_non_object: true
instanceof_class_exists: true
foreach_traversable: true
fix_line_ending: true
fix_doc_comments: true
duplication: true
deprecated_code_usage: true
deadlock_detection_in_loops: true
code_rating: true
closure_use_not_conflicting: true
catch_class_exists: true
blank_line_after_namespace_declaration: false
avoid_multiple_statements_on_same_line: true
avoid_duplicate_types: true
avoid_conflicting_incrementers: true
avoid_closing_tag: true
assignment_of_null_return: true
argument_type_checks: true
duplication: true

filter:
paths: [code/*, tests/*]
paths: [src/*, tests/*]
47 changes: 47 additions & 0 deletions .upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
mappings:
OGDeterminers: TractorCow\OpenGraph\Constants\OGDeterminers
OGGenders: TractorCow\OpenGraph\Constants\OGGenders
OGTypes: TractorCow\OpenGraph\Constants\OGTypes
OpenGraphObjectExtension: TractorCow\OpenGraph\Extensions\OpenGraphObjectExtension
OpenGraphSiteConfigExtension: TractorCow\OpenGraph\Extensions\OpenGraphSiteConfigExtension
IOGApplication: TractorCow\OpenGraph\Interfaces\IOGApplication
IOpenGraphObjectBuilder: TractorCow\OpenGraph\Interfaces\IOpenGraphObjectBuilder
IOGObject: TractorCow\OpenGraph\Interfaces\ObjectTypes\IOGObject
IOGObjectExplicit: TractorCow\OpenGraph\Interfaces\ObjectTypes\IOGObjectExplicit
IOGObjectRequired: TractorCow\OpenGraph\Interfaces\ObjectTypes\IOGObjectRequired
IOGMusic: TractorCow\OpenGraph\Interfaces\Music\IOGMusic
IOGMusicSongList: TractorCow\OpenGraph\Interfaces\Music\IOGMusicSongList
IOGMusicAlbum: TractorCow\OpenGraph\Interfaces\Music\IOGMusicAlbum
IOGMusicPlaylist: TractorCow\OpenGraph\Interfaces\Music\IOGMusicPlaylist
IOGMusicRadioStation: TractorCow\OpenGraph\Interfaces\Music\IOGMusicRadioStation
IOGMusicSong: TractorCow\OpenGraph\Interfaces\Music\IOGMusicSong
IOGSongAlbum: TractorCow\OpenGraph\Interfaces\Music\Relations\IOGSongAlbum
IOGAuthoredTagged: TractorCow\OpenGraph\Interfaces\Other\IOGAuthoredTagged
IOGTagged: TractorCow\OpenGraph\Interfaces\Other\IOGTagged
IOGArticle: TractorCow\OpenGraph\Interfaces\Other\IOGArticle
IOGBook: TractorCow\OpenGraph\Interfaces\Other\IOGBook
IOGProfile: TractorCow\OpenGraph\Interfaces\Other\IOGProfile
IOGWebsite: TractorCow\OpenGraph\Interfaces\Other\IOGWebsite
IMediaFile: TractorCow\OpenGraph\Interfaces\Other\Relations\IMediaFile
IOGVideo: TractorCow\OpenGraph\Interfaces\Video\IOGVideo
IOGVideoEpisode: TractorCow\OpenGraph\Interfaces\Video\IOGVideoEpisode
IOGVideoMovie: TractorCow\OpenGraph\Interfaces\Video\IOGVideoMovie
IOGVideoOther: TractorCow\OpenGraph\Interfaces\Video\IOGVideoOther
IOGVideoTVShow: TractorCow\OpenGraph\Interfaces\Video\IOGVideoTVShow
IOGVideoActor: TractorCow\OpenGraph\Interfaces\Video\Relations\IOGVideoActor
OGMusic: TractorCow\OpenGraph\ObjectBuilders\Music\AbstractOGMusic
OGMusicAlbum: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicAlbum
OGMusicPlaylist: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicPlaylist
OGMusicRadioStation: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicRadioStation
OGMusicSong: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicSong
OpenGraphBuilder: TractorCow\OpenGraph\ObjectBuilders\OpenGraphBuilder
OGArticle: TractorCow\OpenGraph\ObjectBuilders\Other\OGArticle
OGBook: TractorCow\OpenGraph\ObjectBuilders\Other\OGBook
OGProfile: TractorCow\OpenGraph\ObjectBuilders\Other\OGProfile
OGWebsite: TractorCow\OpenGraph\ObjectBuilders\Other\OGWebsite
OGVideo: TractorCow\OpenGraph\ObjectBuilders\Video\AbstractOGVideo
OGVideoEpisode: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoEpisode
OGVideoMovie: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoMovie
OGVideoOther: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoOther
OGVideoTVShow: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoTVShow
OpenGraph: TractorCow\OpenGraph\OpenGraph
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ with Facebook.

## Requirements

* SilverStripe 3.1
* PHP 5.3
* SilverStripe 4+
* PHP 5.6+

## Installation Instructions

* Extract all files into the 'opengraph' folder under your Silverstripe root, or install using composer
* Install using composer

```bash
composer require "tractorcow/silverstripe-opengraph" "3.1.*@dev"
composer require "tractorcow/silverstripe-opengraph" "4@dev"
```

* Ensure the namespace is defined in your template with ``` <html $OGNS> ```
Expand All @@ -44,11 +44,11 @@ Override these in your own `mysite/_config/OpenGraph.yml` or `mysite/_config.php
Name: myopengraphsettings
After: '#opengraphsettings'
---
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
application_id: 'SiteConfig'
admin_id: 'SiteConfig'
default_locale: 'en_US'
default_tagbuilder: 'OpenGraphBuilder'
default_tagbuilder: 'TractorCow\OpenGraph\ObjectBuilders\OpenGraphBuilder'

```

Expand All @@ -65,7 +65,7 @@ Any value above can be set to an empty string to disable it completely. E.g.
Name: myopengraphsettings
After: '#opengraphsettings'
---
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
application_id: ''
admin_id: ''
```
Expand All @@ -75,12 +75,13 @@ OpenGraph:
### Implementing Open Graph object properties
To get specific information on each of the fields an opengraph object can have, check
out the various implementations of each in the [interfaces/ObjectTypes](interfaces/ObjectTypes) folder,
out the various implementations of each in the [src/Interfaces/ObjectTypes](src/Interfaces/ObjectTypes) folder,
or in the [_config/OpenGraphTypes.yml](_config/OpenGraphTypes.yml) file for the list of
types and their respective interfaces.
The basic opengraph object has a set of required properties (as defined by IOGObjectRequired)
and additionally a set of optional properties (as defined by IOGObjectExplicit).
The basic opengraph object has a set of required properties (as defined by
`TractorCow\OpenGraph\Interfaces\ObjectTypes\IOGObjectRequired`)
and additionally a set of optional properties (as defined by `TractorCow\OpenGraph\Interfaces\ObjectTypes\IOGObjectExplicit`).

Since most of the field values are generated by the page extension class OpenGraphPageExtension
automatically, you don't need to explicitly implement either of these. These should however
Expand Down Expand Up @@ -113,13 +114,13 @@ If you wish to add a new og:type you will need to:
* Register your object type with the following code:

```php
OpenGraph::register_type('type-name', IOGMyObjectInterface, MyObjectTagBuilder);
TractorCow\OpenGraph\OpenGraph::register_type('type-name', IOGMyObjectInterface, MyObjectTagBuilder);
```

Or better still, do this directly in yaml as below

```yaml
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
types:
'type-name':
interface: IOGMyObjectInterface
Expand Down Expand Up @@ -164,10 +165,10 @@ You can decorate the OpenGraphBuilder object instead of extending it if you need
to add additional tags to all object types.

The example below shows how to add extra fields from the Page and SiteConfig
to the set of opengraph tags.
to the set of OpenGraph tags.

```php
OpenGraphBuilder::add_extension('OpengraphBuilderExtension');
TractorCow\OpenGraph\ObjectBuilders\OpenGraphBuilder::add_extension('OpenGraphBuilderExtension');
class OpengraphBuilderExtension extends Extension {
Expand All @@ -182,9 +183,9 @@ class OpengraphBuilderExtension extends Extension {
}
```

### Disabling opengraph for a single page (or page type)
### Disabling Open Graph for a single page (or page type)

If you need to disable opengraph for any page then a null value for `getOGType()`
If you need to disable Open Graph for any page then a null value for `getOGType()`
will disable tag generation.

```php
Expand All @@ -200,9 +201,9 @@ NonOGPage extends Page {
### Using DataObjects as pages

See [https://github.com/tractorcow/silverstripe-opengraph/wiki/Using-DataObjects-as-Pages](https://github.com/tractorcow/silverstripe-opengraph/wiki/Using-DataObjects-as-Pages)
for how to extend your `DataObject` with `OpenGraphObjectExtension`.
for how to extend your `DataObject` with `TractorCow\OpenGraph\Extensions\OpenGraphObjectExtension`.

* Add the `OpenGraphObjectExtension` extension to your object
* Add the `TractorCow\OpenGraph\Extensions\OpenGraphObjectExtension` extension to your object
* Implement `AbsoluteLink` on your object
* Implement `MetaTags` on your object, making sure to call `$this->extend('MetaTags', $tags);`
* Make sure the actual page type being viewed delegates the meta tag generation to your dataobject
Expand Down
7 changes: 4 additions & 3 deletions _config/Extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: 'opengraphextensions'
---
Page:
extensions:
- 'OpenGraphObjectExtension'
SiteConfig:
- TractorCow\OpenGraph\Extensions\OpenGraphObjectExtension

SilverStripe\SiteConfig\SiteConfig:
extensions:
- 'OpenGraphSiteConfigExtension'
- TractorCow\OpenGraph\Extensions\OpenGraphSiteConfigExtension
4 changes: 2 additions & 2 deletions _config/OpenGraph.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
Name: opengraphsettings
---
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
application_id: 'SiteConfig'
admin_id: 'SiteConfig'
default_locale: 'en_US'
default_tagbuilder: 'OpenGraphBuilder'
default_tagbuilder: TractorCow\OpenGraph\ObjectBuilders\OpenGraphBuilder
3 changes: 1 addition & 2 deletions _config/OpenGraphLocales.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## See https://www.facebook.com/translations/FacebookLocales.xml for this master list
Name: opengraphlocales
---
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
locales:
af_ZA: 'Afrikaans'
ar_AR: 'Arabic'
Expand Down Expand Up @@ -82,4 +82,3 @@ OpenGraph:
zh_CN: 'Simplified Chinese (China)'
zh_HK: 'Traditional Chinese (Hong Kong)'
zh_TW: 'Traditional Chinese (Taiwan)'

50 changes: 25 additions & 25 deletions _config/OpenGraphTypes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
# This list may be added to to create new object types
Name: opengraphobjecttypes
---
OpenGraph:
TractorCow\OpenGraph\OpenGraph:
types:
'music.song':
interface: IOGMusicSong
tagbuilder: OGMusicSong
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicSong
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicSong
'music.album':
interface: IOGMusicAlbum
tagbuilder: OGMusicAlbum
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicAlbum
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicAlbum
'music.playlist':
interface: IOGMusicPlaylist
tagbuilder: OGMusicPlaylist
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicPlaylist
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicPlaylist
'music.radio_station':
interface: IOGMusicRadioStation
tagbuilder: OGMusicRadioStation
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Music\IOGMusicRadioStation
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Music\OGMusicRadioStation
'video.movie':
interface: IOGVideoMovie
tagbuilder: OGVideoMovie
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Video\IOGVideoMovie
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoMovie
'video.episode':
interface: IOGVideoEpisode
tagbuilder: OGVideoEpisode
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Video\IOGVideoEpisode
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoEpisode
'video.tv_show':
interface: IOGVideoTVShow
tagbuilder: OGVideoTVShow
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Video\IOGVideoTVShow
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoTVShow
'video.other':
interface: IOGVideoOther
tagbuilder: OGVideoOther
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Video\IOGVideoOther
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Video\OGVideoOther
'article':
interface: IOGArticle
tagbuilder: OGArticle
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Other\IOGArticle
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Other\OGArticle
'book':
interface: IOGBook
tagbuilder: OGBook
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Other\IOGBook
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Other\OGBook
'profile':
interface: IOGProfile
tagbuilder: OGProfile
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Other\IOGProfile
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Other\OGProfile
'website':
interface: IOGWebsite
tagbuilder: OGWebsite
interface: TractorCow\OpenGraph\Interfaces\ObjectTypes\Other\IOGWebsite
tagbuilder: TractorCow\OpenGraph\ObjectBuilders\Other\OGWebsite
15 changes: 0 additions & 15 deletions code/Constants/OGDeterminers.php

This file was deleted.

Loading

0 comments on commit 8f0c9e0

Please sign in to comment.