Browse Source

Append other link to page links in BaseLinkBlock (#344)

* Append other link to page links in BaseLinkBlock
* Write to error log in azure pipelines
Vince Salvino 4 years ago
parent
commit
4b689a88da

+ 2 - 1
ci/compare-codecov.ps1

@@ -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
 }

+ 2 - 1
ci/make-docs.ps1

@@ -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.

+ 2 - 1
ci/run-flake8.ps1

@@ -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.

+ 4 - 0
ci/run-tests.ps1

@@ -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

+ 3 - 1
coderedcms/blocks/base_blocks.py

@@ -279,7 +279,9 @@ class LinkStructValue(blocks.StructValue):
         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

+ 10 - 0
docs/features/blocks/baselink.rst

@@ -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 - 0
docs/features/blocks/button.rst

@@ -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 - 0
docs/features/blocks/imagelink.rst

@@ -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 - 0
docs/features/blocks/index.rst

@@ -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 - 0
docs/features/index.rst

@@ -4,6 +4,7 @@ Features
 .. toctree::
     :maxdepth: 2
 
+    blocks/index
     import_export
     mailchimp
     page_types/index

+ 3 - 0
docs/releases/v0.19.0.rst

@@ -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`.