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

Suggestions for Redwood support #1

Open
wants to merge 4 commits into
base: redwood
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
6 changes: 3 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
python-version:
- '3.8'
- '3.10'
- '3.11'
pip-version:
- 22.0.4
- 23.2.1
Expand Down Expand Up @@ -49,10 +49,10 @@ jobs:
uses: actions/checkout@v1
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'
- name: Install dependencies
run: |
pip install coverage
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
This XBlock allows course authors to create and edit course content in Markdown
and displays it as HTML.

## Version compatibility matrix
You must install a supported release of this plugin to match the Open
edX and Tutor version you are deploying.

| Open edX release | Tutor version | Xblock version |
|------------------|-------------------|----------------|
| Olive | `>=15.0, <16` | `<2.0` |
| Palm | `>=16.0, <17` | `<2.0` |
| Quince | `>=17.0, <18` | `<2.0` |
| Redwood | `>=18.0, <19` | `>=2.0` |


## Installation with [Tutor](https://docs.tutor.edly.io)
You may install the markdown-xblock to your Tutor environment by adding it to the `OPENEDX_EXTRA_PIP_REQUIREMENTS` list in `config.yml`:
```
Expand Down
26 changes: 21 additions & 5 deletions markdown_xblock/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
from django.conf import settings as django_settings
from xblock.core import XBlock
from xblock.fields import List, Scope, String
from xblock.fragment import Fragment
from xblockutils.resources import ResourceLoader
from xblockutils.settings import XBlockWithSettingsMixin
from xblockutils.studio_editable import StudioEditableXBlockMixin, loader
try: # XBlock 2+
from web_fragments.fragment import Fragment
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import XBlockWithSettingsMixin
from xblock.utils.studio_editable import StudioEditableXBlockMixin, loader
except ImportError: # Compatibility with XBlock<2
from xblock.fragment import Fragment
from xblockutils.resources import ResourceLoader
from xblockutils.settings import XBlockWithSettingsMixin
from xblockutils.studio_editable import StudioEditableXBlockMixin, loader

from .utils import _

Expand Down Expand Up @@ -276,12 +282,22 @@ def get_editable_fields(self):
return fields

@classmethod
def parse_xml(cls, node, runtime, keys, id_generator):
def parse_xml(cls, node, runtime, keys, id_generator=None):
"""
Use `node` to construct a new block.
"""
block = runtime.construct_xblock_from_class(cls, keys)

# Prior to XBlock 2.0, id_generator is passed in.
# Since XBlock 2.0, we grab it from the runtime.
#
# TODO: Once we decide to drop support for versions prior to
# XBlock 2 (i.e. Open edX releases before Redwood), we can
# drop id_generator from the method signature, and always rely
# on runtime.id_generator.
if not id_generator:
id_generator = runtime.id_generator

# Read markdown content from file and add to editor.
url_name = node.get('url_name', node.get('slug'))
location = id_generator.create_definition(node.tag, url_name)
Expand Down
3 changes: 1 addition & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Requirements for app run

xblock-utils<=4.0.0
xblock-sdk<0.9.0
xblock-sdk
django-statici18n<2.5
edx-i18n-tools<1.4
Mako==1.2.4
Expand Down
3 changes: 2 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ mock==3.0.5

# Github requirements
django-pyfs<3.2
xblock-sdk<0.9.0
xblock-sdk<0.9.0;python_version<"3.9"
xblock-sdk;python_version>="3.9"
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def package_data(pkg, roots):
'markdown_xblock',
],
install_requires=[
'XBlock<=1.9',
'XBlock<2; python_version < "3.9"',
'XBlock<5; python_version >= "3.9"',
'markdown2>=2.3.9',
'Pygments>=2.0.1'
'Pygments>=2.0.1',
],
setup_requires=[
'setuptools-scm',
Expand Down
19 changes: 15 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tox]
envlist = py{38,310,312},flake8,report
envlist = py{38,311,312},pipdeptree{,-requirements},flake8,report

[gh-actions]
python =
3.8: py38,flake8
3.10: py310,flake8
3.12: py312,flake8
3.8: py38,pipdeptree{,-requirements},flake8
3.11: py311,pipdeptree{,-requirements},flake8
3.12: py312,pipdeptree{,-requirements},flake8

[flake8]
ignore = E124
Expand All @@ -27,6 +27,17 @@ deps =
-rrequirements/base.txt
-rrequirements/test.txt

[testenv:pipdeptree]
deps =
pipdeptree
commands = pipdeptree -w fail

[testenv:pipdeptree-requirements]
deps =
-rrequirements/base.txt
pipdeptree
commands = pipdeptree -w fail

[testenv:flake8]
deps = flake8
commands = flake8
Expand Down
Loading