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

Ensure compatibility with Moodle 4.0 & update Unit tests #7

Open
wants to merge 23 commits into
base: MOODLE_311_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cc4a621
Remove some errors and warnings from codechecker
Badatos Nov 16, 2022
c0d446c
Upgrade grunt versions
Badatos Nov 16, 2022
59709d7
Update ci.yml
Badatos Nov 16, 2022
17ab479
Remove codechecker warnings and errors
Badatos Nov 16, 2022
f033280
Remove some phpdoc errors (86 errors before this commit)
Badatos Nov 16, 2022
bf0c3f0
Update ci.yml
Badatos Nov 16, 2022
16f9724
Correct some phpDocs errors.
Badatos Nov 17, 2022
095066d
correct namespace
Badatos Nov 17, 2022
959d896
remove namespace for behat_filter_oembed
Badatos Nov 17, 2022
ab3678b
More phpDoc corrections.
Badatos Nov 17, 2022
315e067
Replace div class=oembed-provider-details by span for w3c compatibili…
Badatos Nov 17, 2022
d2602ff
Specify which grunt tasks to run in github ci
Badatos Nov 18, 2022
e1c1c2b
add php 8.0 and Moodle 4.0 to github CI
Badatos Nov 22, 2022
05edda5
Add mysqli to Github CI
Badatos Nov 22, 2022
036431f
put NODE_VERSION in env vars for Github CI
Badatos Nov 22, 2022
609757f
revert node.js to 16.18.1 in github CI
Badatos Nov 22, 2022
6a0790b
SET max_input_vars PHP value required for Moodle 400
Badatos Nov 22, 2022
dec18f7
add some missing namespace declaration
Badatos Nov 23, 2022
12ec34f
corrections related to namespaces in phpunit tests
Badatos Nov 23, 2022
cc7020a
Display debugging message when download_file_content can't reach url …
Badatos Nov 23, 2022
fc0e4eb
Remove Poll EveryWhere from Unit Tests, as they no more features oembed.
Badatos Nov 24, 2022
e1cb654
Update version.php
Badatos Nov 24, 2022
32f9aba
Update CHANGES.md
Badatos Nov 24, 2022
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
21 changes: 13 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ jobs:
fail-fast: false
matrix:
include:
- php: '7.3'
moodle-branch: 'MOODLE_39_STABLE'
database: 'pgsql'
node: '16.18.1'
- php: '7.4'
moodle-branch: 'MOODLE_311_STABLE'
database: 'mariadb'
node: '14.15.0'
- php: '7.3'
moodle-branch: 'MOODLE_310_STABLE'
database: 'pgsql'
node: '14.15.0'
node: '16.18.1'
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
database: 'mariadb'
node: '16.18.1'

services:
postgres:
Expand All @@ -42,12 +46,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: plugin

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -56,6 +60,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: zip, gd, mbstring, pgsql, mysqli
ini-values: max_input_vars=5000

- name: Deploy moodle-plugin-ci
run: |
Expand Down Expand Up @@ -114,4 +119,4 @@ jobs:

- name: behat
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
run: moodle-plugin-ci behat --profile chrome
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ Icon
# Grunt stuff
.sass-cache
node_modules

# phpDocumentor
phpdoc
tools
.phive
28 changes: 25 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Release Notes
# Release Notes

Release 3.8.0 (Build 2019112600)
## 4.0.0 (Build - 2022112400)
Compatibility with Moodle 4.0
Remove errors and warnings from codechecker and phpdoc

## 3.8.0 (Build 2019112600)
Compatibility with Moodle 3.8 & 3.9
Updated subplugin declaration file to new subplugins.json structure.

(see CHANGES.TXT in release 3.3 for earlier changes.)
## 3.3.0
An xpath change was required in the Behat tests in order to get Behat to pass due to changes in Moodle's output.

## 3.2
the plugin was rewritten to utilize the oembed provider definitions from [http://oembed.com/providers.json](http://oembed.com/providers.json).
The previous provider definitions that were hardcoded, but not present in the oembed provider list, were added as "local" definitions to avoid regression errors.

## 3.2.0.0 (Alpha)
Change highlights:

- Oembed providers defintions are downloaded from http://oembed.com/providers.json and stored in the Moodle database, rather than code.
- Oembed defintions are refreshed nightly with new additions and deletions.
- Management screen allows for administrators to save provider defintions as local overrides not refreshed by oembed.com.
- Two types of tags can be used for filtering. The one desired can be configured.
- Lazy loading can be turned on or off; default is on. This can improve site performance.
- Provider management screen allows enable/disable, and edit as local as well as providing all of the provider information.
- A subplugin system is in place to allow providers not stored at oembed.com to define oembed information.
Some of the existing Microsoft providers have been rewritten as these.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Moodle oEmbed Filter #
![Licence](https://img.shields.io/github/license/PoetOS/moodle-filter_oembed)


## Description
This is a text filter for Moodle that converts urls from many different media sites into embeded content.
Embed code is retrieved from the original site so should work even if the site changes embed format.

## Installation
1. Download the source files. (zip file is available under download section)
2. Unzip the package
3. Copy the "oembed" folder to moodle/filter on the Moodle server.
4. Login as an admin on the Moodle site and install the filter.

### Upgrading from earlier versions
Upgrade per normal procedures. Your settings from earlier plugins will be preserved.

**NOTE** Embed providers may change the text that identifies them.
It is possible that media embedded previously on your site no
longer meets the provider text definitions, and as such, may not show up as embedded media.
Check the provider definition to see if the media link needs to change.

## To use
Under Plugins > Filters > Oembed Filter / Settings, you can choose:

- The type of tag to identify the embedded media.
- To delay the media loading or load it immediately.

By default the oembed filter disables all providers.
You can change this under *Plugins > Filters > Oembed Filter / Manage providers*.

When inserting a media link url into a discussion, create a hyperlink and insert the url as the target.
When the discussion is posted the url will be changed into the embed content.

**N.B.** if you enable the *Convert URLs into links and images* filter ahead of this then it is easier for users to embed media.

The embedded media providers are in three groups:

- Downloaded from [//oembed.com/providers.json](https://oembed.com/providers.json). This is the main repository that manages Oembed provider definitions.
These are updated regularly in the cron job, and can change.
- Plugins provided to extend media providers provided in earlier versions of the plugin, but not contained in the provider repo.
- Local providers which allow a site administrator to save a downloaded one locally, so that it does not change with download updates.
This also allows new providers to be created that are not part of the omebed repo.
33 changes: 0 additions & 33 deletions README.txt

This file was deleted.

6 changes: 4 additions & 2 deletions classes/db/abstract_dbrow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/**
* Base class for classes which map to db tables.
* @package filter_oembed
* @author Guy Thomas <[email protected]>
* @copyright Copyright (c) 2016 Blackboard Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -24,8 +25,9 @@
namespace filter_oembed\db;
use stdClass;

defined('MOODLE_INTERNAL') || die();

/**
* Base class for classes which map to db tables.
*/
class abstract_dbrow {

/**
Expand Down
9 changes: 5 additions & 4 deletions classes/db/providerrow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@

/**
* Provider Row.
* @package filter_oembed
* @author Guy Thomas <[email protected]>
* @copyright Copyright (c) 2016 Blackboard Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace filter_oembed\db;

defined('MOODLE_INTERNAL') || die();

class providerrow extends abstract_dbrow{
/**
* Provider Row class.
*/
class providerrow extends abstract_dbrow {
/**
* @var int id
*/
Expand Down
5 changes: 4 additions & 1 deletion classes/forms/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

/**
* Provider mform.
* @package filter_oembed
* @author Guy Thomas <[email protected]>
* @copyright Copyright (c) 2016 Blackboard Inc.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,7 +28,9 @@
defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot.'/lib/formslib.php');

/**
* Provider mform.
*/
class provider extends moodleform {
/**
* Define this form - is called from parent constructor.
Expand Down
7 changes: 5 additions & 2 deletions classes/output/managementpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Management page output
*
* @package filter_oembed
* @author Mike Churchward <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,8 +28,9 @@
use filter_oembed\db\providerrow;
use filter_oembed\provider\provider;

defined('MOODLE_INTERNAL') || die();

/**
* Management page class.
*/
class managementpage implements \renderable, \templatable {

/**
Expand Down
7 changes: 4 additions & 3 deletions classes/output/providermodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* providermodel output
*
* @package filter_oembed
* @author Guy Thomas <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,11 +29,10 @@
use filter_oembed\provider\provider;
use filter_oembed\db\providerrow;

defined('MOODLE_INTERNAL') || die();

/**
* Class providermodel
* @package filter_oembed\output
*
* @package filter_oembed
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2016 The POET Group
*/
Expand Down
7 changes: 4 additions & 3 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

/**
* Renderer for oembed filter.
* @package filter_oembed
* @author gthomas2
* @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace filter_oembed\output;

defined('MOODLE_INTERNAL') || die();

/**
* Renderer for oembed filter.
*/
class renderer extends \plugin_renderer_base {

/**
Expand Down
13 changes: 9 additions & 4 deletions classes/plugininfo/oembedprovider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* filter_oembed capabilities list
* @package filter_oembed
* @author Mike Churchward <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright 2016 The POET Group
*/

namespace filter_oembed\plugininfo;

defined('MOODLE_INTERNAL') || die();

/**
* filter_oembed capabilities list
*/
class oembedprovider extends \core\plugininfo\base {
/**
* filter_oembed has the uninstall capability
* @return boolean always true
*/
public function is_uninstall_allowed() {
return true;
}
}
}
7 changes: 3 additions & 4 deletions classes/provider/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Base class for oembed endpoints.
* @package filter_oembed
* @author Mike Churchward <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -23,8 +24,6 @@

namespace filter_oembed\provider;

defined('MOODLE_INTERNAL') || die();

/**
* Base class for oembed endpoints.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down Expand Up @@ -53,7 +52,7 @@ class endpoint {

/**
* Constructor.
* @param $data JSON decoded array or data object containing all endpoint data.
* @param any $data JSON decoded array or data object containing all endpoint data.
*/
public function __construct($data = null) {
if (is_object($data)) {
Expand Down Expand Up @@ -87,4 +86,4 @@ public function __get($name) {
throw new \coding_exception($name.' is not a publicly accessible property of '.get_class($this));
}
}
}
}
Loading