WordPress plugin intelligence profile

Documents from Git

A plugin to inject and render files in a WordPress post or page directly from most popular Git platforms. Currently supported file types: Markdown, J …

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 5.8
Current version2.2.0
WordPress coverageTested up to WordPress 5.8
Minimum stackWP 5.0.0 · PHP 7.0
Directory statusactive
Last directory update9 Oct 20215y ago
Active installations200Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 3 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Documents from Git version 2.2.0 as active, updated 5y ago and tested up to WordPress 5.8.

Overview

About this plugin

com/gis-ops/wordpress-markdown-git

This WordPress Plugin lets you easily publish, collaborate on and version control your [ Markdown, Jupyter notebook ] documents directly from your favorite remote Git platform, even if it’s self-hosted.

The advantages are:

  • Write documents in your favorite editor and just push to your remote repository to update your blog instantly
  • Use the power of version control: publish different versions of the document in different posts, i.e. from another branch or commit than latest master
  • Easy to update by your readers via pull requests, minimizing the chance of stale tutorials

The following document types are currently supported:

  • Markdown
  • Jupyter notebooks ( only for public repositories )

The following platforms are currently supported:

  • Github
  • Bitbucket
  • Gitlab

Usage

Note, this plugin uses Github’s wonderful /markdown API to render to HTML. This comes with 2 caveats:

  • Unless authenticated, the rate limit is set at 60 requests per minute. Since v1.1.0 the plugin is capable of statically caching content. In case that’s not dynamic enough for you, your only option currently is to not use any cache in which case every document will be pulled from your provider every time someone opens it on your site. Then it’s strongly recommended to create a Github access token and register it with the plugin. Then the rate limit will be set to 5000 requests per hour. See Global attributes section for details on how to do that.
  • The Markdown content cannot exceed 400 KB, so roughly 400 000 characters incl whitespace. If not a monographic dissertation, this should not be an applicable limit though.

Shortcodes

The plugin features a variety of shortcodes.

Publish documents

The document-specific shortcodes follow a pattern of [git-<platform>-<action>], where

  • <platform> can be one of
  • github: if you use Github as your VCS platform
  • bitbucket: if you use Bitbucket as your VCS platform
  • gitlab: if you use Gitlab as your VCS platform
  • <action> can be one of
  • markdown: Render your Markdown files hosted on your VCS platform in Github’s rendering style
  • jupyter: Render your Jupyter notebook hosted on your VCS platfrom ( only for public repositories )
  • checkout: Renders a small badge-like box with a link to the document and the date of the last commit
  • history: Renders a <h2> section with the last commit dates, messages and authors

Manipulate rendering style

Additionally, there’s an enclosing shortcode [git-add-css] which adds a <div id="git-add-css" class="<classes_attribute>" to wrap its contents. That way you can manipulate the style freely with additional CSS classes. Follow these steps:

  • Add a CSS file to your theme’s root folder, which contains some classes, e.g. class1, class2, class3
  • Enqueue the CSS file by adding wp_enqueue_style('my-style', get_template_directory_uri().'/my-style.css'); to the theme’s functions.php

-

:

[git-add-css classes="class1 class2 class3"]

]

]

]

[/git-add-css]

Attributes

Each shortcode takes a few attributes, indicating if it’s required for public or private repositories:

Attribute

Action

Public repo

Private repo

Type

Description

url

all except git-add-css

:ballot_box_with_check:

:ballot_box_with_check:

string

g. md

user

all except git-add-css

:negative_squared_cross_mark:

:ballot_box_with_check:

string

The user name (not email) of an authorized user

token

all except git-add-css

:negative_squared_cross_mark:

:ballot_box_with_check:

string

The access token/app password for the authorized user

cache_ttl

all except git-add-css

:negative_squared_cross_mark:

:negative_squared_cross_mark:

integer

The time in seconds that the plugin will cache, only for cache_strategy=static.

cache_strategy

all except git-add-css

:negative_squared_cross_mark:

:negative_squared_cross_mark:

integer

Only static caching is implemented so far. dynamic caching is on the way!

limit

history

:negative_squared_cross_mark:

:negative_squared_cross_mark:

integer

Limits the history of commits to this number. Default 5.

classes

git-add-css

:ballot_box_with_check:

:ballot_box_with_check:

string

The additional CSS classes to render the content with

Global attributes

Since most attributes will be the same across the entire system, this plugin offers the possibility to set all attributes globally except for url:

json.

json.

Caching

Often we need to prioritize speed when loading content and, in addition, it is very costly to fetch, load and format the content every time we need to read the content of the post.

This plugin soon offers 2 methods for caching, static and dynamic which can be set via the cache_strategy property.

Static caching ( cache_strategy=static )

This is the default strategy, as it doesn’t require any user action.

The property cache_ttl sets how many seconds the content cache will keep alive.

Currently there’s no way to flush the cache manually. However, changing cache_ttl or the history limit will create a new cache.

Dynamic caching ( cache_strategy=dynamic )

This is not implemented yet. See #20 for details.

Token authorization

You need to authorize via user and token if you intend to publish from a private repository. You don’t need to authorize if the repository is open.

However, keep in mind that some platforms have stricter API limits for anonymous requests which are greatly extended if you provide your credentials. So even for public repos it could make sense. And unless you use this plugin’s caching capabilities, it’s strongly recommended to register a Github access token regardless of the VCS hosting platform, see the beginning of the chapter.

How to generate the token depends on your platform:

  • Github: Generate a Personal Access Token following these instructions
  • Bitbucket: Generate a App Password following these instructions
  • Gitlab: Generate a Personal Access Token following these instructions

This plugin needs only Read access to your repositories. Keep that in mind when creating an access token.

Examples

com/tutorials/.

Publish Markdown from Github

md"]

Publish Markdown from Github with 1 hour cache

md" cache_ttl="3600" cache_strategy="static"]

Publish Jupyter notebook from Github

ipynb"]

Publish from a private repository

md"]

Display last commit and document URL from Bitbucket

md"]

Display commit history from Gitlab

md"]

Use additional CSS classes to style

The following example will put a dashed box around the whole post:

`

[git-add-css classes=”md-dashedbox”]

md”]

md”]

md”]

[/git-add-css]

`

With the following CSS file contents enqueued to your theme:

`css

md_dashedbox {

position: relative;

75em;

border: 3px dashed;

padding: 10px;

margin-bottom:15px

}

markdown-github {

color:white;

line-height: 20px;

padding: 0px 5px;

position: absolute;

background-color: #345;

top: -3px;

left: -3px;

text-transform:none;

font-size:1em;

font-family: “Helvetica Neue”,Helvetica,Arial,sans-serif;

}

`

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • bitbucket
  • github
  • jupyter
  • markdown
  • notebook
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 5.8

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 5.8.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to5.8
Minimum requirementsWordPress 5.0.0 · PHP 7.0
Update activity9 Oct 20215y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.