Compare commits

...

80 Commits

Author SHA1 Message Date
Steve Boyd
55d18d8392 Merge branch '2.4' into 2 2024-07-11 16:17:47 +12:00
Guy Sartorelli
0b94f4b8a9
Merge pull request #115 from creative-commoners/pulls/2.4/composer
MNT Add dev version of framework
2024-07-11 10:00:07 +12:00
Steve Boyd
a2b6f45abd MNT Add dev version of framework 2024-07-10 12:45:43 +12:00
github-actions
b12eee33ed Merge branch '2.4' into 2 2024-03-03 22:44:42 +00:00
Guy Sartorelli
0a17d0c537
Merge pull request #101 from creative-commoners/pulls/2.4/exists
FIX Ensure page has extension before calling method
2024-03-04 11:43:49 +13:00
Steve Boyd
66da923502 FIX Ensure page has extension before calling method 2024-02-29 14:05:44 +13:00
github-actions
3c922398ca Merge branch '2.4' into 2 2024-02-08 11:14:51 +00:00
Guy Sartorelli
82872780eb
TLN Update translations (#99) 2024-02-07 16:14:36 +13:00
github-actions
900aae6a25 Merge branch '2.4' into 2 2023-08-24 11:15:01 +00:00
Guy Sartorelli
d082606ded
ENH Update translations (#88) 2023-08-21 13:18:55 +12:00
Steve Boyd
4129c23c0f Merge branch '2.4' into 2 2023-06-16 12:18:08 +12:00
Guy Sartorelli
84f1ed3914
Merge pull request #86 from creative-commoners/pulls/2.4/tx-1686724968
ENH Update translations
2023-06-15 10:06:18 +12:00
Steve Boyd
b11db96d7a ENH Update translations 2023-06-14 18:42:48 +12:00
Guy Sartorelli
1f015f119c
Merge branch '2.4' into 2 2023-04-26 12:47:28 +12:00
Guy Sartorelli
ebae2446a9
MNT Revert erroneous dependency changes (#83) 2023-03-28 17:12:13 +13:00
Maxime Rainville
633b85537e
Merge pull request #82 from creative-commoners/pulls/2/dispatch-ci
MNT Use gha-dispatch-ci
2023-03-23 12:04:15 +13:00
Steve Boyd
df5845176f MNT Use gha-dispatch-ci 2023-03-21 12:05:01 +13:00
Guy Sartorelli
4afd8ce074
MNT Update development dependencies 2023-03-10 16:35:17 +13:00
Guy Sartorelli
1e78dfc828
MNT Update release dependencies 2023-03-10 16:35:14 +13:00
Guy Sartorelli
b56ae94e87
MNT Update development dependencies 2023-03-10 12:21:30 +13:00
Guy Sartorelli
1ec4a141e3
Merge pull request #81 from creative-commoners/pulls/2/tx-1678080252
ENH Update translations
2023-03-08 10:32:29 +13:00
Steve Boyd
d44e506d00 ENH Update translations 2023-03-06 18:24:12 +13:00
Sabina Talipova
48220dad3a
Merge pull request #76 from creative-commoners/pulls/2/stop-using-depr
API Stop using deprecated API
2022-12-05 16:37:21 +13:00
Steve Boyd
6699b9074a API Stop using deprecated API 2022-11-24 13:10:46 +13:00
Guy Sartorelli
8041c15dc7
Merge pull request #75 from creative-commoners/pulls/2/depr-messages
API Update deprecations
2022-11-21 10:00:28 +13:00
Steve Boyd
9f6b6f9d8a API Update deprecations 2022-11-16 12:00:17 +13:00
Maxime Rainville
831c178514
Merge pull request #74 from creative-commoners/pulls/2/fix-userdoc-deploy
MNT Fix github action for deploying userdocs
2022-08-24 11:13:45 +12:00
Guy Sartorelli
2e1dc4a46e
MNT Fix github action for deploying userdocs 2022-08-23 14:42:19 +12:00
Guy Sartorelli
c5fdbcbd72
Merge pull request #73 from creative-commoners/pulls/2/userhelp-fix
DOC Correct title for userhelp
2022-08-22 11:00:33 +12:00
Maxime Rainville
2ba0438277 DOC Correct title for userhelp 2022-08-20 21:57:04 +12:00
Steve Boyd
656094763b Merge branch '2.3' into 2 2022-08-02 19:03:51 +12:00
Steve Boyd
d18a07213e Merge branch '2.2' into 2.3 2022-08-02 19:03:46 +12:00
Guy Sartorelli
e8da1e07bf
Merge pull request #72 from creative-commoners/pulls/2.2/standardise-modules
MNT Standardise modules
2022-08-02 16:01:03 +12:00
Steve Boyd
abb248242f MNT Standardise modules 2022-08-01 16:23:48 +12:00
Steve Boyd
75237f89db Merge branch '2.3' into 2 2022-07-25 11:49:37 +12:00
Steve Boyd
befc7f07d3 Merge branch '2.2' into 2.3 2022-07-25 11:49:33 +12:00
Guy Sartorelli
c5f4a5ccdb
Merge pull request #71 from creative-commoners/pulls/2.2/module-standards
MNT Use GitHub Actions CI
2022-07-15 12:00:16 +12:00
Steve Boyd
9433c0542a MNT Use GitHub Actions CI 2022-07-05 22:18:11 +12:00
Guy Sartorelli
f93f32d22b
Merge pull request #70 from creative-commoners/pulls/2/php81
ENH PHP 8.1 compatibility
2022-04-26 17:57:34 +12:00
Steve Boyd
600a4b2cde ENH PHP 8.1 compatibility 2022-04-13 13:53:29 +12:00
Maxime Rainville
7195e2a833
Merge pull request #69 from creative-commoners/pulls/2/php74
DEP Set PHP 7.4 as the minimum version
2022-02-18 22:10:56 +13:00
Steve Boyd
8171761d39 DEP Set PHP 7.4 as the minimum version 2022-02-10 17:45:12 +13:00
Steve Boyd
933c58128b Merge branch '2.1' into 2 2021-11-18 17:51:00 +13:00
Maxime Rainville
feb6218035
Merge pull request #67 from creative-commoners/pulls/2/sapphire-test-nine
API phpunit 9 support
2021-11-01 22:46:24 +13:00
Steve Boyd
2671406a86 API phpunit 9 support 2021-10-27 18:17:31 +13:00
Maxime Rainville
52f303d497 Update translations 2021-10-05 14:25:05 +13:00
Steve Boyd
baee472c9f Merge branch '2.1' into 2 2021-09-04 18:09:12 +12:00
Maxime Rainville
25ff52c1fc MNT Remove obsolete branch-alias 2021-08-27 12:06:28 +12:00
Maxime Rainville
b4ce6caead Update translations 2021-08-27 11:27:35 +12:00
Steve Boyd
42ea538f0f
Update build status badge 2021-01-21 16:45:17 +13:00
Steve Boyd
a7251dba0f Merge branch '2.0' into 2 2020-11-11 17:56:18 +13:00
Serge Latyntsev
c4ba8bf3a9
Merge pull request #66 from creative-commoners/pulls/2.0/shared-config
FIX Quote yml, use shared travis config, sminnee/phpunit
2020-11-10 16:18:37 +13:00
Steve Boyd
5cc58a1269 FIX Quote yml, use shared travis config, sminnee/phpunit 2020-11-09 17:14:48 +13:00
Robbie Averill
747cf4d68d
Merge pull request #65 from creative-commoners/pulls/2.0/travis
Update travis 2.0
2020-06-23 09:40:16 -07:00
Steve Boyd
f473126c9f Update travis 2020-06-23 16:41:21 +12:00
Garion Herman
952c7c3592
Merge pull request #64 from creative-commoners/pulls/2/merge-up
Merge up from 2.0
2020-06-12 14:58:46 +12:00
Maxime Rainville
1f832bcdc4 Merge branch '2.0' into 2 2020-06-12 14:47:54 +12:00
Serge Latyntsev
4d499524cd
Merge pull request #63 from creative-commoners/pulls/2.0/update-travis
Update travis matrix
2020-02-18 12:06:08 +13:00
Steve Boyd
ece9566bcb Update travis matrix 2020-02-18 11:59:52 +13:00
Aaron Carlino
8de3ec1dfc
META: Add github action to build docs 2019-12-19 13:55:11 +13:00
Garion Herman
5aef1bace1
Merge pull request #61 from creative-commoners/pulls/2/travis-ci
Travis config update
2019-11-26 14:46:42 +13:00
Serge Latyntcev
a56946b68b Travis config update 2019-11-26 14:38:45 +13:00
Robbie Averill
08539df0af Merge branch '2.0' 2019-05-10 10:16:35 +12:00
Robbie Averill
aae09ae51f Update translations 2019-05-10 10:16:23 +12:00
Robbie Averill
9260d8c744 Bump postgres version in Travis configuration to 2.1.x 2018-11-08 10:45:59 +02:00
Robbie Averill
831f03a2b8
Bump Postgres for Travis builds on SilverStripe 4.2+ 2018-08-17 23:45:25 +12:00
Robbie Averill
247039ff0e Merge branch '2.0' 2018-07-26 15:19:44 +12:00
Dylan Wagstaff
2986d7e0c3
Merge pull request #57 from creative-commoners/pulls/2.0/fix-cache-mode
FIX Separate tests, ensure versioned cache mode does not interfere
2018-06-19 10:51:28 +12:00
Robbie Averill
0be030efd1 Add various recipe versions to Travis matrix 2018-06-18 22:56:10 +12:00
Robbie Averill
bd59ce6200 FIX Separate tests, ensure versioned cache mode does not interfere 2018-06-18 22:54:33 +12:00
Robbie Averill
0356e1e0a2
Merge pull request #56 from creative-commoners/pulls/master/add-supported-module-badge
Add supported module badge to readme
2018-06-18 10:09:09 +12:00
Dylan Wagstaff
9065f82d79 Add supported module badge to readme 2018-06-15 17:52:36 +12:00
Robbie Averill
3b1c682a54 Merge branch '2.0' 2018-06-11 15:38:24 +12:00
Robbie Averill
d48fab6faa Remove obsolete branch alias 2018-06-11 15:38:06 +12:00
Dylan Wagstaff
5b38663322
Merge pull request #52 from silverstripe/docs/pulls/2.0/update-docs
Update docs to match rename of checkbox in CMS
2018-04-05 09:57:03 +12:00
Raissa North
205d077384 Update docs to match rename of checkbox in CMS 2018-04-05 09:47:06 +12:00
Dylan Wagstaff
3a6fe66e2f
Merge pull request #53 from silverstripe/pulls/2.0/update-developer-docs
DOCS Both version feeds are disabled by default
2018-03-27 21:01:21 +13:00
Raissa North
0c199bcae0
DOCS Both version feeds are disabled by default 2018-03-27 15:40:48 +13:00
Dylan Wagstaff
7b3d282802
Merge pull request #51 from creative-commoners/pulls/2.0/Content-with-Contents
FIX allow allchanges to handle removed Page types
2018-02-14 10:10:20 +13:00
Dylan Wagstaff
093af10c8a FIX allow allchanges to handle removed Page types
If a there exists at some point in the history a class that no longer
exists, Versioned will create it as a `DataObject` as opposed to some form
of the `SiteTree` superclass. This would break the absolute link
funcitonality, so we should make the version at least an instance of
SiteTree so we can generate the link accurately (without fatal errors).
2018-02-13 12:11:27 +13:00
26 changed files with 241 additions and 164 deletions

11
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,11 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
ci:
name: CI
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1

View File

@ -0,0 +1,16 @@
name: Deploy Userhelp Docs
on:
push:
branches:
- '3'
- '2'
- 'master'
paths:
- 'docs/en/userguide/**'
jobs:
deploy:
name: deploy-userhelp-docs
runs-on: ubuntu-latest
steps:
- name: Run build hook
run: curl -X POST -d {} https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK }}

16
.github/workflows/dispatch-ci.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Dispatch CI
on:
# At 11:10 AM UTC, only on Sunday and Monday
schedule:
- cron: '10 11 * * 0,1'
jobs:
dispatch-ci:
name: Dispatch CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Dispatch CI
uses: silverstripe/gha-dispatch-ci@v1

17
.github/workflows/keepalive.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Keepalive
on:
workflow_dispatch:
# The 8th of every month at 11:50am UTC
schedule:
- cron: '50 11 8 * *'
jobs:
keepalive:
name: Keepalive
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Keepalive
uses: silverstripe/gha-keepalive@v1

View File

@ -1,15 +0,0 @@
inherit: true
build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]
checks:
php:
code_rating: true
duplication: true
filter:
paths: [src/*, tests/*]

View File

@ -1,34 +0,0 @@
language: php
env:
global:
- COMPOSER_ROOT_VERSION=2.0.x-dev
matrix:
include:
- php: 5.6
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
- php: 7.0
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.1
env: DB=PGSQL PHPUNIT_COVERAGE_TEST=1
- php: 7.2
env: DB=MYSQL PHPUNIT_TEST=1
before_script:
# Init PHP
- phpenv rehash
- phpenv config-rm xdebug.ini
# Install composer dependencies
- composer validate
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql 2.0.x-dev; fi
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi
after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi

View File

@ -1,8 +1,9 @@
[main]
host = https://www.transifex.com
[silverstripe-versionfeed.master]
[o:silverstripe:p:silverstripe-versionfeed:r:master]
file_filter = lang/<lang>.yml
source_file = lang/en.yml
source_lang = en
type = YML

View File

@ -1,8 +1,7 @@
# Version Feed
[![Build Status](http://img.shields.io/travis/silverstripe/silverstripe-versionfeed.svg?style=flat)](https://travis-ci.org/silverstripe/silverstripe-versionfeed)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/silverstripe/silverstripe-versionfeed/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-versionfeed/?branch=master)
[![codecov](https://codecov.io/gh/silverstripe/silverstripe-versionfeed/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-versionfeed)
[![CI](https://github.com/silverstripe/silverstripe-versionfeed/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/silverstripe-versionfeed/actions/workflows/ci.yml)
[![Silverstripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
## Overview
@ -10,13 +9,13 @@ The module creates an RSS feed on each page with their change history, as well a
## Requirements
* SilverStripe ^4
* Silverstripe ^4
**Note:** For a SilverStripe 3.x compatible version, please use [the 1.x release line](https://github.com/silverstripe/silverstripe-versionfeed/tree/1.2).
**Note:** For a Silverstripe 3.x compatible version, please use [the 1.x release line](https://github.com/silverstripe/silverstripe-versionfeed/tree/1.2).
## Installation
Install with composer by running `composer require silverstripe/versionfeed` in the root of your SilverStripe project.
Install with composer by running `composer require silverstripe/versionfeed` in the root of your Silverstripe project.
## Usage

View File

@ -6,7 +6,7 @@ SilverStripe\Core\Injector\Injector:
ContentFilter:
class: SilverStripe\VersionFeed\Filters\CachedContentFilter
constructor:
- %$RateLimitFilter
- '%$RateLimitFilter'
Psr\SimpleCache\CacheInterface.VersionFeedController:
factory: SilverStripe\Core\Cache\CacheFactory
constructor:
@ -22,4 +22,4 @@ SilverStripe\CMS\Controllers\ContentController:
- SilverStripe\VersionFeed\VersionFeedController
SilverStripe\VersionFeed\VersionFeedController:
dependencies:
ContentFilter: %$ContentFilter
ContentFilter: '%$ContentFilter'

View File

@ -16,12 +16,14 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/cms": "^4",
"silverstripe/versioned": "^1",
"silverstripe/siteconfig": "^4"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^9.5",
"silverstripe/framework": "^4.10",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
@ -30,11 +32,6 @@
"SilverStripe\\VersionFeed\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@ -9,11 +9,14 @@ the extensions defined on the extension.
### Enabling / Disabling
The `allchanges` feed can be disabled by setting the `SilverStripe\VersionFeed\VersionFeed.allchanges_enabled` config to false.
By default the `allchanges` and `changes` feed are disabled.
The `allchanges` feed can be enabled by setting the `SilverStripe\VersionFeed\VersionFeed.allchanges_enabled` config to true. If this is true, then the allchanges feed can still be disabled by unchecking the "All page changes" checkbox in the "Settings" section in the CMS.
Likewise, the `changes` feed for each page can be globally enabled by setting the `SilverStripe\VersionFeed\VersionFeed.changes_enabled`
config to true. If this is true, then each page can still be individually disabled by unchecking the
'Make history public' checkbox in the CMS under page settings.
Likewise, the `changes` feed for each page can be globally disabled by setting the `SilverStripe\VersionFeed\VersionFeed.changes_enabled`
config to false. If this left true, then each page can still be individually disabled by unchecking the
'Make History Public' checkbox in the CMS under page settings.
See [user documentation on enabling / disabling](userguide/index.md#enabling--disabling).
### Default RSS action

View File

@ -1,5 +1,7 @@
---
title: Content change RSS
summary: Adds page or site wide RSS feeds that display content changes
---
# Content change RSS
@ -16,12 +18,12 @@ Make sure that your SilverStripe installation has the [versionfeed](http://addon
There are two feeds that are automatically created for each page:
* Page changes: This feed will display all published versions of the page, highlighting any additions or deletions with underscores or strikethroughs. It is accessible with the `changes` action - so `http://mysite.com/mypage/changes`
* Page changes: This feed will display all published versions of the page, highlighting any additions or deletions with underscores or strikethroughs respectively. It is accessible with the `changes` action - so `http://mysite.com/mypage/changes`
* Site changes: This will aggregate all the per-page change feeds into one feed and display the most recent 20. It is accessible from any page with the `allchanges` action - so `http://mysite.com/home/allchanges`
## Enabling / disabling
You can enable or disable the feed on a per-page basis by checking or unchecking the *Public History* checkbox in the Settings tab of each page. If a page has the Public History option, unchecked, it will not appear in the allchanges feed.
You can enable or disable the feed on a per-page basis by checking or unchecking the *Make history public* checkbox (if available) in the Settings tab of each page. If a page has the Make history public option unchecked, it will not appear in the allchanges feed.
The allchanges feed can also be disabled by unchecking the "All page changes" checkbox in the "Settings" section in the cms.
@ -29,4 +31,4 @@ The allchanges feed can also be disabled by unchecking the "All page changes" ch
A page's history will be completely visible when it has public history enabled, even if some updates were made when it was restricted to only being viewed by authenticated users. So if a page has ever had confidential data on it, it is best to not enable this feature unless the data has entered the public domain.
There is a warning explaining this fact next to the *Public History* checkbox.
There is a warning explaining this fact next to the *Make history public* checkbox.

View File

@ -6,6 +6,8 @@ en:
TITLECHANGED: 'Title has changed:'
Warning: 'Publicising the history will also disclose the changes that have at the time been protected from the public view.'
Warning2: 'Changing access settings in such a way that this page or pages under it become publicly<br>accessible may result in publicising all historical changes on these pages too. Please review<br> this section''s "Public history" settings to ascertain only intended information is disclosed.'
db_PublicHistory: 'Public history'
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'All page changes'
ALLCHANGESLABEL: 'Make global changes feed public'
db_AllChangesEnabled: 'All changes enabled'

View File

@ -6,6 +6,8 @@ eo:
TITLECHANGED: 'Titolo estas ŝanĝita:'
Warning: 'Publikigi la historion ankaŭ malkaŝos la ŝanĝojn ĝis tiam protektitajn kontraŭ publika vido.'
Warning2: 'Ŝanĝi la alirajn agordojn tiel ke ĉi tiu paĝo, aŭ paĝoj sub ĝi, fariĝas publike alireblaj <br>eble rezultigos ke publikiĝos ĉiuj historiaj ŝanĝoj en tiuj paĝoj. Bonvole rekonsideru <br> la sekcion "Publika historio" de ĉi tiu sekcio, por certigi ke nur intencita informo publikiĝu.'
db_PublicHistory: 'Publika historio'
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'Ĉiuj paĝaj ŝanĝoj'
ALLCHANGESLABEL: 'Ĉieaj ŝanĝoj fluu en publikan'
db_AllChangesEnabled: 'Ĉiuj ŝanĝoj enŝaltitaj'

11
lang/it.yml Normal file
View File

@ -0,0 +1,11 @@
it:
SilverStripe\VersionFeed\VersionFeed:
LABEL: 'Rendere pubblica la cronologia'
SINGLEPAGEFEEDTITLE: 'Aggiornare alla pagina {title}'
SITEFEEDTITLE: 'Aggiornare a {title}'
TITLECHANGED: 'Il titolo è cambiato:'
Warning: 'Pubblicare la cronologia divulgherà anche i cambiamenti che sono stati precedentemente protetti dalla vista pubblica.'
Warning2: 'Cambiare la modalità di accesso in modo che la pagina o le pagine sottostanti diventino pubbliche<br>può comportare la pubblicazione della cronologia dei cambiamenti di queste pagine. Si prega di rivedere<br>le impostazioni della sezione "Cronologia pubblica" per assicurarsi che siano divulgate solo le informazioni desiderate.'
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'Tutti i cambiamenti pagina'
ALLCHANGESLABEL: 'Rendere pubblico il feed dei cambiamenti globali'

13
lang/sk.yml Normal file
View File

@ -0,0 +1,13 @@
sk:
SilverStripe\VersionFeed\VersionFeed:
LABEL: 'Zverejniť históriu'
SINGLEPAGEFEEDTITLE: 'Aktualizácie stránky {title}'
SITEFEEDTITLE: 'Aktualizácie {title}'
TITLECHANGED: 'Názov sa zmenil:'
Warning: 'Zverejnením histórie sa zverejnia aj zmeny, ktoré boli v tom čase chránené pred zrakom verejnosti.'
Warning2: 'Zmena nastavení prístupu tak, aby sa táto stránka alebo stránky pod ňou stali verejne prístupné,<br>môže viesť k zverejneniu všetkých historických zmien aj na týchto stránkach.<br> Skontrolujte nastavenia v časti "Verejná história", aby ste sa uistili, že sú zverejnené iba zamýšľané informácie.'
db_PublicHistory: 'Verejná história'
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'Všetky zmeny stránky'
ALLCHANGESLABEL: 'Zverejnite informačný kanál globálnych zmien'
db_AllChangesEnabled: 'Všetky zmeny povolené'

12
lang/sl.yml Normal file
View File

@ -0,0 +1,12 @@
sl:
SilverStripe\VersionFeed\VersionFeed:
LABEL: 'Javno objavi zgodovino'
SINGLEPAGEFEEDTITLE: 'Posodobitve strani ''{title}'' '
SITEFEEDTITLE: 'Posodobitve {title}'
TITLECHANGED: 'Spremenjen naslov:'
Warning: 'Objava zgodovine bo razkrila tudi spremembe, ki do sedaj niso bile javno objavljene.'
Warning2: 'Sprememba nastavitev dostopa tako, da so so ta stran ali njene podstrani dostopne javnosti, <br> lahko povzroči objavo tudi vseh sprememb na omenjenih straneh. Podrobno preverite <br> seznam sprememb in se prepričajte, da boste razkrili samo tiste informacije, ki jih želite.'
db_PublicHistory: 'Javna zgodovina'
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'Vse spremembe'
ALLCHANGESLABEL: 'Javno objavi seznam s krovnimi spremembami'

View File

@ -1,8 +1,8 @@
zh:
SilverStripe\VersionFeed\VersionFeed:
LABEL: '将历史记录公开'
LABEL: 将历史记录公开
SINGLEPAGEFEEDTITLE: '更新至 {title} 页面'
SITEFEEDTITLE: '更新至 {title}'
TITLECHANGED: '标题已更改:'
Warning: '发布历史记录还会在公开视图中显示受保护事件内进行的改动。'
Warning2: '用这种方式更改访问设置会使得本页及下级页面变为公开的<br>可能还会使得这些页面的所有变动历史记录也变为公开的。请查阅<br>本节的“公开历史记录”设置,确保只将需要的信息披露出来。'
TITLECHANGED: 标题已更改:
Warning: 发布历史记录还会在公开视图中显示受保护事件内进行的改动。
Warning2: 用这种方式更改访问设置会使得本页及下级页面变为公开的<br>可能还会使得这些页面的所有变动历史记录也变为公开的。请查阅<br>本节的“公开历史记录”设置,确保只将需要的信息披露出来。

View File

@ -2,6 +2,9 @@
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<file>src</file>
<file>tests</file>
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>

View File

@ -39,7 +39,7 @@ abstract class ContentFilter
/**
* Gets the cache to use
*
* @return Zend_Cache_Frontend
* @return CacheInterface
*/
protected function getCache()
{

View File

@ -5,6 +5,7 @@ namespace SilverStripe\VersionFeed\Filters;
use SilverStripe\Core\Config\Config;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Versioned\Versioned;
/**
* Provides rate limiting of execution of a callback
@ -67,13 +68,13 @@ class RateLimitFilter extends ContentFilter
// Add global identifier
if ($this->config()->get('lock_bypage')) {
$key .= '_' . md5($itemkey);
$key .= '_' . md5($itemkey ?? '');
}
// Add user-specific identifier
if ($this->config()->get('lock_byuserip') && Controller::has_curr()) {
$ip = Controller::curr()->getRequest()->getIP();
$key .= '_' . md5($ip);
$key .= '_' . md5($ip ?? '');
}
return $key;

View File

@ -2,6 +2,7 @@
namespace SilverStripe\VersionFeed;
use SilverStripe\Dev\Deprecation;
use SilverStripe\CMS\Model\SiteTreeExtension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CheckboxField;
@ -12,6 +13,7 @@ use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\Parsers\Diff;
use SilverStripe\CMS\Model\SiteTree;
class VersionFeed extends SiteTreeExtension
{
@ -76,7 +78,7 @@ class VersionFeed extends SiteTreeExtension
$offset = $highestVersion ? "AND \"SiteTree_Versions\".\"Version\"<='".(int)$highestVersion."'" : '';
// Get just enough elements for diffing. We need one more than desired to have something to compare to.
$qLimit = (int)$limit + 1;
$versions = $this->owner->allVersions(
$versions = $this->owner->Versions(
"\"WasPublished\"='1' AND \"CanViewType\" IN ('Anyone', 'Inherit') $offset",
"\"SiteTree\".\"LastEdited\" DESC, \"SiteTree\".\"ID\" DESC",
$qLimit
@ -114,7 +116,16 @@ class VersionFeed extends SiteTreeExtension
}
// Copy the link so it can be cached.
$version->GeneratedLink = $version->AbsoluteLink();
$oldPage = $version->getField('object');
if (!$oldPage instanceof SiteTree) {
// We only need enough info to generate the link...
$oldPage = SiteTree::create([
'ID' => $oldPage->ID,
'URLSegment' => $oldPage->URLSegment,
'ParentID' => $oldPage->ParentID
]);
}
$version->GeneratedLink = $oldPage->AbsoluteLink();
}
// Omit the versions that haven't been visibly changed (only takes the above fields into consideration).
@ -161,7 +172,7 @@ class VersionFeed extends SiteTreeExtension
/**
* Compile a list of changes to the current page, excluding non-published and explicitly secured versions.
*
* @deprecated 2.0.0 Use VersionFeed::getDiffList instead
* @deprecated 2.0.0 Use VersionFeed::getDiffList() instead
*
* @param int $highestVersion Top version number to consider.
* @param boolean $fullHistory Set to true to get the full change history, set to false for a single diff.
@ -171,6 +182,7 @@ class VersionFeed extends SiteTreeExtension
*/
public function getDiffedChanges($highestVersion = null, $fullHistory = true, $limit = 100)
{
Deprecation::notice('2.0.0', 'Use VersionFeed::getDiffList() instead');
return $this->getDiffList(
$highestVersion,
$fullHistory ? $limit : 1

View File

@ -77,7 +77,7 @@ class VersionFeedController extends Extension
// Cache the diffs to remove DOS possibility.
$target = $this->owner;
$key = implode('_', array('changes', $this->owner->ID, $this->owner->Version));
$key = implode('_', array('changes', $target->ID, $target->Version));
$entries = $this->filterContent($key, function () use ($target) {
return $target->getDiffList(null, Config::inst()->get(VersionFeed::class, 'changes_limit'));
});
@ -119,7 +119,7 @@ class VersionFeedController extends Extension
if ($lastChange) {
// Cache the diffs to remove DOS possibility.
$key = 'allchanges'
. preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited'])
. preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited'] ?? '')
. (Security::getCurrentUser() ? Security::getCurrentUser()->ID : 'public');
$changeList = $this->filterContent($key, function () use ($latestChanges) {
$changeList = new ArrayList();
@ -191,6 +191,7 @@ class VersionFeedController extends Extension
{
if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')
|| !SiteConfig::current_site_config()->AllChangesEnabled
|| !method_exists($this->owner, 'getSiteRSSLink')
) {
return;
}

View File

@ -3,9 +3,11 @@
namespace SilverStripe\VersionFeed\Tests;
use Page;
use PageController;
use Psr\SimpleCache\CacheInterface;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Director;
use SilverStripe\Core\Cache\CacheFactory;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FunctionalTest;
@ -22,23 +24,28 @@ class VersionFeedFunctionalTest extends FunctionalTest
protected $baseURI = 'http://www.fakesite.test';
protected static $required_extensions = array(
'Page' => array(VersionFeed::class),
'PageController' => array(VersionFeedController::class),
);
protected static $required_extensions = [
Page::class => [VersionFeed::class],
PageController::class => [VersionFeedController::class],
];
protected $userIP;
protected function setUp()
/**
* @var CacheInterface
*/
protected $cache;
protected function setUp(): void
{
Director::config()->set('alternate_base_url', $this->baseURI);
parent::setUp();
$cache = Injector::inst()->get(
$this->cache = Injector::inst()->get(
CacheInterface::class . '.VersionFeedController'
);
$cache->clear();
$this->cache->clear();
$this->userIP = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
@ -52,9 +59,12 @@ class VersionFeedFunctionalTest extends FunctionalTest
Config::modify()->set(RateLimitFilter::class, 'lock_bypage', false);
Config::modify()->set(RateLimitFilter::class, 'lock_byuserip', false);
Config::modify()->set(RateLimitFilter::class, 'lock_cooldown', false);
// Ensure any version based caches read from the live cache
Versioned::set_reading_mode(Versioned::DEFAULT_MODE);
}
protected function tearDown()
protected function tearDown(): void
{
Director::config()->set('alternate_base_url', null);
@ -63,9 +73,9 @@ class VersionFeedFunctionalTest extends FunctionalTest
parent::tearDown();
}
public function testPublicHistory()
public function testPublicHistoryPublicHistoryDisabled()
{
$page = $this->createPageWithChanges(array('PublicHistory' => false));
$page = $this->createPageWithChanges(['PublicHistory' => false]);
$response = $this->get($page->RelativeLink('changes'));
$this->assertEquals(
@ -76,17 +86,20 @@ class VersionFeedFunctionalTest extends FunctionalTest
$response = $this->get($page->RelativeLink('allchanges'));
$this->assertEquals(200, $response->getStatusCode());
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$this->assertFalse(
(bool)$xml->channel->item,
'With Page\'s "PublicHistory" disabled, `allchanges` action should not have an item in the channel'
);
}
$page = $this->createPageWithChanges(array('PublicHistory' => true));
public function testPublicHistoryPublicHistoryEnabled()
{
$page = $this->createPageWithChanges(['PublicHistory' => true]);
$response = $this->get($page->RelativeLink('changes'));
$this->assertEquals(200, $response->getStatusCode());
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$this->assertTrue(
(bool)$xml->channel->item,
'With Page\'s "PublicHistory" enabled, `changes` action should have an item in the channel'
@ -94,7 +107,7 @@ class VersionFeedFunctionalTest extends FunctionalTest
$response = $this->get($page->RelativeLink('allchanges'));
$this->assertEquals(200, $response->getStatusCode());
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$this->assertTrue(
(bool)$xml->channel->item,
'With "PublicHistory" enabled, `allchanges` action should have an item in the channel'
@ -107,15 +120,11 @@ class VersionFeedFunctionalTest extends FunctionalTest
Config::modify()->set(RateLimitFilter::class, 'lock_timeout', 20);
Config::modify()->set(CachedContentFilter::class, 'cache_enabled', true);
$page1 = $this->createPageWithChanges(array('PublicHistory' => true, 'Title' => 'Page1'));
$page2 = $this->createPageWithChanges(array('PublicHistory' => true, 'Title' => 'Page2'));
$page1 = $this->createPageWithChanges(['PublicHistory' => true, 'Title' => 'Page1']);
$page2 = $this->createPageWithChanges(['PublicHistory' => true, 'Title' => 'Page2']);
// Artifically set cache lock
Config::modify()->set(RateLimitFilter::class, 'lock_byuserip', false);
$cache = Injector::inst()->get(
CacheInterface::class . '.VersionFeedController'
);
$cache->set(RateLimitFilter::CACHE_PREFIX, time() + 10);
$this->cache->set(RateLimitFilter::CACHE_PREFIX, time() + 10);
// Test normal hit
$response = $this->get($page1->RelativeLink('changes'));
@ -127,13 +136,13 @@ class VersionFeedFunctionalTest extends FunctionalTest
// Test page specific lock
Config::modify()->set(RateLimitFilter::class, 'lock_bypage', true);
$key = implode('_', array(
$key = implode('_', [
'changes',
$page1->ID,
Versioned::get_versionnumber_by_stage(SiteTree::class, 'Live', $page1->ID, false)
));
$key = RateLimitFilter::CACHE_PREFIX . '_' . md5($key);
$cache->set($key, time() + 10);
]);
$key = RateLimitFilter::CACHE_PREFIX . '_' . md5($key ?? '');
$this->cache->set($key, time() + 10);
$response = $this->get($page1->RelativeLink('changes'));
$this->assertEquals(429, $response->getStatusCode());
$this->assertGreaterThan(0, $response->getHeader('Retry-After'));
@ -144,42 +153,37 @@ class VersionFeedFunctionalTest extends FunctionalTest
// Test rate limit hit by IP
Config::modify()->set(RateLimitFilter::class, 'lock_byuserip', true);
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$cache->set(RateLimitFilter::CACHE_PREFIX . '_' . md5('127.0.0.1'), time() + 10);
$this->cache->set(RateLimitFilter::CACHE_PREFIX . '_' . md5('127.0.0.1'), time() + 10);
$response = $this->get($page1->RelativeLink('changes'));
$this->assertEquals(429, $response->getStatusCode());
$this->assertGreaterThan(0, $response->getHeader('Retry-After'));
// Test rate limit doesn't hit other IP
$_SERVER['REMOTE_ADDR'] = '127.0.0.20';
$cache->set(RateLimitFilter::CACHE_PREFIX . '_' . md5('127.0.0.1'), time() + 10);
$this->cache->set(RateLimitFilter::CACHE_PREFIX . '_' . md5('127.0.0.1'), time() + 10);
$response = $this->get($page1->RelativeLink('changes'));
$this->assertEquals(200, $response->getStatusCode());
// Restore setting
Config::modify()->set(RateLimitFilter::class, 'lock_byuserip', false);
Config::modify()->set(RateLimitFilter::class, 'lock_timeout', 0);
Config::modify()->set(CachedContentFilter::class, 'cache_enabled', false);
}
public function testChangesActionContainsChangesForCurrentPageOnly()
{
$page1 = $this->createPageWithChanges(array('Title' => 'Page1'));
$page2 = $this->createPageWithChanges(array('Title' => 'Page2'));
$page1 = $this->createPageWithChanges(['Title' => 'Page1']);
$page2 = $this->createPageWithChanges(['Title' => 'Page2']);
$response = $this->get($page1->RelativeLink('changes'));
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$titles = array_map(function ($item) {
return (string)$item->title;
}, $xml->xpath('//item'));
}, $xml->xpath('//item') ?? []);
// TODO Unclear if this should contain the original version
$this->assertContains('Changed: Page1', $titles);
$this->assertNotContains('Changed: Page2', $titles);
$response = $this->get($page2->RelativeLink('changes'));
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$titles = array_map(function ($item) {
return (string)$item->title;
}, $xml->xpath('//item'));
}, $xml->xpath('//item') ?? []);
// TODO Unclear if this should contain the original version
$this->assertNotContains('Changed: Page1', $titles);
$this->assertContains('Changed: Page2', $titles);
@ -187,14 +191,14 @@ class VersionFeedFunctionalTest extends FunctionalTest
public function testAllChangesActionContainsAllChangesForAllPages()
{
$page1 = $this->createPageWithChanges(array('Title' => 'Page1'));
$page2 = $this->createPageWithChanges(array('Title' => 'Page2'));
$page1 = $this->createPageWithChanges(['Title' => 'Page1']);
$page2 = $this->createPageWithChanges(['Title' => 'Page2']);
$response = $this->get($page1->RelativeLink('allchanges'));
$xml = simplexml_load_string($response->getBody());
$xml = simplexml_load_string($response->getBody() ?? '');
$titles = array_map(function ($item) {
return str_replace('Changed: ', '', (string) $item->title);
}, $xml->xpath('//item'));
}, $xml->xpath('//item') ?? []);
$this->assertContains('Page1', $titles);
$this->assertContains('Page2', $titles);
}
@ -203,32 +207,32 @@ class VersionFeedFunctionalTest extends FunctionalTest
{
$page = new Page();
$seed = array_merge(array(
$seed = array_merge([
'Title' => 'My Title',
'Content' => 'My Content'
), $seed);
], $seed);
$page->update($seed);
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->publishSingle();
$page->update(array(
$page->update([
'Title' => 'Changed: ' . $seed['Title'],
'Content' => 'Changed: ' . $seed['Content'],
));
]);
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->publishSingle();
$page->update(array(
$page->update([
'Title' => 'Changed again: ' . $seed['Title'],
'Content' => 'Changed again: ' . $seed['Content'],
));
]);
$page->write();
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$page->publishSingle();
$page->update(array(
$page->update([
'Title' => 'Unpublished: ' . $seed['Title'],
'Content' => 'Unpublished: ' . $seed['Content'],
));
]);
$page->write();
return $page;
@ -241,11 +245,11 @@ class VersionFeedFunctionalTest extends FunctionalTest
{
// Nested loop through each configuration
foreach (array(true, false) as $publicHistory_Page) {
$page = $this->createPageWithChanges(array('PublicHistory' => $publicHistory_Page, 'Title' => 'Page'));
foreach ([true, false] as $publicHistory_Page) {
$page = $this->createPageWithChanges(['PublicHistory' => $publicHistory_Page, 'Title' => 'Page']);
// Test requests to 'changes' action
foreach (array(true, false) as $publicHistory_Config) {
foreach ([true, false] as $publicHistory_Config) {
Config::modify()->set(VersionFeed::class, 'changes_enabled', $publicHistory_Config);
$expectedResponse = $publicHistory_Page && $publicHistory_Config ? 200 : 404;
$response = $this->get($page->RelativeLink('changes'));
@ -253,8 +257,8 @@ class VersionFeedFunctionalTest extends FunctionalTest
}
// Test requests to 'allchanges' action on each page
foreach (array(true, false) as $allChanges_Config) {
foreach (array(true, false) as $allChanges_SiteConfig) {
foreach ([true, false] as $allChanges_Config) {
foreach ([true, false] as $allChanges_SiteConfig) {
Config::modify()->set(VersionFeed::class, 'allchanges_enabled', $allChanges_Config);
$siteConfig = SiteConfig::current_site_config();
$siteConfig->AllChangesEnabled = $allChanges_SiteConfig;

View File

@ -44,18 +44,18 @@ class VersionFeedTest extends SapphireTest
// Strip spaces from test output because they're not reliably maintained by the HTML Tidier
$cleanDiffOutput = function ($val) {
return str_replace(' ', '', strip_tags($val));
return str_replace(' ', '', strip_tags($val ?? ''));
};
$this->assertContains(
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle') ?? []),
'Detects published title changes'
);
$this->assertNotContains(
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle') ?? []),
'Ignores unpublished title changes'
);
}