Skip to content

Commit

Permalink
Append other link to page links in BaseLinkBlock (#344)
Browse files Browse the repository at this point in the history
* Append other link to page links in BaseLinkBlock
* Write to error log in azure pipelines
  • Loading branch information
vsalvino authored Aug 2, 2020
1 parent 7392edd commit 4b689a8
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ci/compare-codecov.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ elseif ($branchlinerate -eq $masterlinerate) {
exit 0
}
else {
Write-Host "Coverage decreased by $change% 😭" -ForegroundColor Red
# Write the error in a way that shows up as the failure reason in Azure Pipelines.
Write-Host "##vso[task.LogIssue type=error;]Coverage decreased by $change% 😭"
exit 4
}
3 changes: 2 additions & 1 deletion ci/make-docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ if ($ExitCode -eq 0) {
Write-Host "Docs have been built! 📜" -ForegroundColor Green
}
else {
Write-Host "There were warnings or errors building docs. 😭" -ForegroundColor Red
# Write the error in a way that shows up as the failure reason in Azure Pipelines.
Write-Host "##vso[task.LogIssue type=error;]There were warnings or errors building the docs."
}

# Exit with sphinx's code.
Expand Down
3 changes: 2 additions & 1 deletion ci/run-flake8.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ if ($ExitCode -eq 0) {
Write-Host -ForegroundColor Green "[✔] Flake8 passed with no errors"
}
else {
Write-Host -ForegroundColor Red "[X] Flake8 exited with errors. Please resolve issues above."
# Write the error in a way that shows up as the failure reason in Azure Pipelines.
Write-Host "##vso[task.LogIssue type=error;]Flake8 exited with errors. Please resolve issues above."
}

# Unset working directory and exit with flake8's exit code.
Expand Down
4 changes: 4 additions & 0 deletions ci/run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if ($ExitCode -eq 0) {
Write-Output "All unit tests passed! 🎉"
Write-Output "Code coverage: $LineRate%"
}
else {
# Write the error in a way that shows up as the failure reason in Azure Pipelines.
Write-Host "##vso[task.LogIssue type=error;]Unit tests failed."
}

# Unset working directory and exit with pytest's code.
Pop-Location
Expand Down
4 changes: 3 additions & 1 deletion coderedcms/blocks/base_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ def url(self):
page = self.get('page_link')
doc = self.get('doc_link')
ext = self.get('other_link')
if page:
if page and ext:
return "{0}{1}".format(page.url, ext)
elif page:
return page.url
elif doc:
return doc.url
Expand Down
10 changes: 10 additions & 0 deletions docs/features/blocks/baselink.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* **Page link** - Reference a page within the CMS.

* **Document link** If a Page is not selected, reference a Document within the
CMS

* **Other link** - If a Page or Document is not selected, the value of this
field will be used as-is. If a Page is selected, then the value of this field
will be appended to the Page URL. This is useful for linking to fragments or
element IDs. For example: Page ``/about/`` with Other link ``#team`` would
then link to ``/about/#team``.
24 changes: 24 additions & 0 deletions docs/features/blocks/button.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Button Block
============

The button block renders an HTML anchor styled as a button. This can be used to
link to pages, documents, or external links.


Field Reference
---------------

Fields and purposes:

.. include:: baselink.rst

* **Button Title** - The text to show on the button. You can insert simple HTML
here as well, such as ``Learn <b>More</b>``.

* **Button Style** - The appearance of the button. This is a choice loaded from
``CODERED_FRONTEND_BTN_STYLE_CHOICES`` Django setting and is inserted as a
CSS class in the HTML.

* **Button Size** - The size of button. This is a choice loaded from
``CODERED_FRONTEND_BTN_SIZE_CHOICES`` Django setting and is inserted as a CSS
class in the HTML.
17 changes: 17 additions & 0 deletions docs/features/blocks/imagelink.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Image Link
==========

The image link block renders an image as an HTML anchor. This can be used to
link to pages, documents, or external links.


Field Reference
---------------

Fields and purposes:

.. include:: baselink.rst

* **Image** - The image to be shown as the content of the anchor.

* **Alt text** - Alternate text to show to search engines and screen readers.
13 changes: 13 additions & 0 deletions docs/features/blocks/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Blocks
======

.. note::
This section is a Work in progress. There are many more blocks included in
CodeRed CMS than those listed below. More documentation will be added over
time before the project reaches an stable 1.0 release.

.. toctree::
:maxdepth: 1

button
imagelink
1 change: 1 addition & 0 deletions docs/features/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Features
.. toctree::
:maxdepth: 2

blocks/index
import_export
mailchimp
page_types/index
Expand Down
3 changes: 3 additions & 0 deletions docs/releases/v0.19.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ New features

* Upgraded to Bootstrap 4.5 and jQuery 3.5.1

* Button and Link blocks can now link to fragments. See new :doc:`block
documentation </features/blocks/index>`.

* ``coderedcms start`` no longer creates a boilerplate Dockerfile. This has
been replaced with a more thorough guide: :doc:`/how_to/docker`.

Expand Down

0 comments on commit 4b689a8

Please sign in to comment.