Does Gramex have inbuild Markdown handler? If yes, how to use that? - gramex

Trying to create a wiki site similar to gramex help document.
For that, I have gramex.yaml that reads
url:
main:
pattern: /$YAMLURL/
handler: FileHandler
kwargs:
index: false
path:
"": $YAMLPATH/{dir}/readme.md
transform:
"*.md":
encoding: utf-8
function: markdown.markdown(content)
headers:
Content-Type: text/html; charset=UTF-8
File tree looks like:
$ tree
.
├── behave
│ └── readme.md
├── gramex.yaml
└── readme.md
But it does not seem to render any MARKDOWN files as HTML.
Do I need to create this markdown.markdown function?
or Is this function readily available in gramex?
Edit 1:
The render issue came because of {dir} in path.
Solution:
Remove {dir} and make the new path as :- $YAMLPATH/readme.md
EDIT 2: NEW PROBLEM
Markdown tables are not rendered
I have a table in the markdown as:
| Criteria | Behave | Pytest |
| --- | --- | --- |
| Readability | Tests are written in natural language format, making them easier to understand by both technical and non-technical stakeholders. | Tests are written in code format, which can be challenging for non-technical stakeholders to understand. |
That must be rendered as:
but the webpage shows:

If you change
function: markdown.markdown(content)
... to
function: markdown.markdown(content, extensions=['extra'])
... it starts working, thanks to the tables extension which is part of the extra extension.
For more Python markdown options, see https://python-markdown.github.io/reference/.
For extensions, see https://python-markdown.github.io/extensions/

Related

How do I write multiple functions in one file?

I am writing my own Jenkins shared library. Currently my lib looks like this:
root
|
|- vars
|---function1.groovy
|---function2.groovy
|---function3.groovy
Each function file contains a call() method and the code that it is executing. How can I combine all those functions in one file?
Put all functions into single file:
root
|
|- vars
|---allFunctions.groovy
Rename functions from call() to:
function1(string) {
echo "function1 - $string"
}
function2(string) {
echo "function2 - $string"
}
Call them from different file (e.g. vars/buildRepo.groovy) as:
allFunctions.function1('Hello world via function1')
allFunctions.function1('Hello world via function2')
Call them from withing same file (e.g. vars/allFunctions.groovy) as:
function1('Hello world via function1')
function1('Hello world via function2')
As #matt-schuchard noted, it is described in https://www.jenkins.io/doc/book/pipeline/shared-libraries/#defining-global-variables on log.groovy example.

Apache Zeppelin-Highcharts displaying blank output

I configured HighCharts on our Zeppelin Tool to implement a drill down functionality.
We placed the below jar files and stated the same in the Dependencies
Zeppelin-highcharts-0.6.4.jar
lift-json_2.11-2.6.3.jar
paranamer-2.4.1.jar
We tried executing the below code-
val bank = spark.read.option("header",true).csv("/u01/zepplin/bank/bank2.csv")
bank.show()
+---+-------+
|age|balance|
+---+-------+
| 20| 40000|
| 30| 60000|
| 50| 70000|
| 80| 90000|
+---+-------+
import com.knockdata.spark.highcharts._
import com.knockdata.spark.highcharts.model._
highcharts(bank.series("x" -> "age", "y" -> sum(col("balance"))).orderBy(col("age"))).plot()
But this code is not able to plot anything, giving a blank out put.It just shows the tile(Chart Title).
To rule out the browser compatibility issue I tried this on all the browsers too.
Am I missing something here.Do we have any alternative for High-charts for custom visualization like drill down etc.
Thanks in Advance

Rails application - How to get TinyMCE to save a pasted image locally

I am running into a very unique edge case with my TinyMCE user experience.
I want to be able to
COPY IMAGE (Right click, copy image on any image on the internet)
PASTE IMAGE (CTRL + V) into TinyMCE editor
and have it save a local copy of this image and serve that.
The problem is a user can paste an image being served in S3 bucket and it is only authenticated for a certain amount of time, then days later the image will not show.
I have looked at TinyMCE - File Image Upload documentation to no avail.
Also looked into TinyMCE Paste Plugin, TinyMCE Local Upload Demo, TinyMCE Docs - Upload Images and dated gem TinyMCE-Rails-ImageUpload
Ultimately, I have a feeling that a custom handler for Paste Preprocess will need to be used
My tinymce.yml configuration follows:
menubar: false
statusbar: false
branding: false
toolbar:
- styleselect | bold italic underline strikethrough | indent outdent | blockquote | image | link | codesample | bullist numlist | table | code | undo redo
plugins:
- link
- codesample
- image
- lists
- code
- table
images_upload_url: "/tinymce_assets"
automatic_uploads: true
relative_urls: false
remove_script_host: false
convert_urls: true
table_responsive_width: true
I feel like this type of problem should be common and there should be a simple solution that I am not seeing. However, if not at all possible, would the solution be to create a custom js function that intercepts paste call, check if it is coming from external url, then decide to create a local image copy and give that url?
Thank you, and any help would be appreciated.

JabRef exportfilter for Wikipedia citation

I want to cite inside Wikipedia sources which are stored in my JabRef Database. According to the jabref-documentation I need a custom exportfilter which is a file like
wikipediacitation.layout. This layout file converts a JabRef database into the wikipedia-syntax for pasting it at the end of an article. The description of the output format is given here. My problem is, that the creation of a Jabref-layout-file seems to be complicated. Can anybody help?
I've found the answer by myself.
The following files have to be created:
wikicite.layout:
<ref name=\bibtexkey>{{cite journal
| author = \author
| title = \title
| year = \year
| journal = \journal
| volume = \volume
| pages = \pages
| url = \url
}}</ref>
wikicite.begin.layout:
==References==
<references>
wikicite.end.layout
</references>
Then, a new export filter has to be added into Jabref (options -> manage custom exports -> add new). But even I've found myself the answer, thanks to Stackoverflow for listening to my problem.

How do you configure pathing in Durandal?

I'm a novice at Durandal but familiar with mvc4. I'm attempting to port an existing application that heavily uses knockout to a SPA framework.
I've been able to get the standard View / ViewModel convention working with the information from this post: https://stackoverflow.com/a/15636715/1693081
I'd like to extend this to a feature based structure because each page has multiple reusable components, I'd like to set up my application directory as follows:
App
|
|--- Pages
| |
| |---Shell
| | |
| | |---Shell.chtml
| | |---Shell.js
| | |---web.config
| |
| |---Dashboard
|
|---Dashboard.chtml
|---Dashboard.js
|--web.config
I thought it would be as simple as commenting out viewLocator.userConvention() and added a new route but this throws a failed to load root module exception.
from my main.js:
app.start().then(function () {
//Replace 'viewmodels' in the moduleId with 'views' to locate the view.
//Look for partial views in a 'views' folder in the root.
//viewLocator.useConvention();
//Show the app by setting the root view model for our application with a transition.
app.setRoot('pages/shell/shell', 'entrance');
});
from my Routeconfig.cs:
routes.MapRoute(
name: "Durandal Page Level Views",
url: "App/Pages/{viewFolder}/{viewName}.html",
defaults: new { controller = "DurandalView", action = "Get" }
);
Am I missing something obvious? The documentation for Durandal suggests that their defaults aren't best for a large application but doesn't give me an idea as to how to solve it out of the box.
Thanks!
I had a work around for this. It turns out that dropping the web.config interferes with the ability to load the js files in each directory. I ended up splitting each page into model and view model folders.
|
|---Pages
|
|---Shell
|
|---View
| |
| |---Shell.html
| |---web.config
|
|---ViewModel
|
|---Shell.js

Resources