Contributors: JamesDiGioia
Donate link: http://jamesdigioia.com/
Tags: gist, code snippets, codepen
Requires at least: 5.2
Requires PHP: 5.6
Tested up to: 5.2
Stable tag: 2.0.0-beta.0
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
A self-hosted alternative to putting your code snippets on Gist.
You use WordPress because you want control over your writing. Why give Gist or Codepen your code snippets? WP-Gistpen is a self-hosted replacement for your WordPress blog.
Features include:
- Revision saving
- Gist import & export
- PrismJS syntax highlighting
- Prism-based text editor
- oEmbed snippet embedding
- Navigate to the 'Add New' in the plugins dashboard
- Search for 'wp-gistpen'
- Click 'Install Now'
- Activate the plugin on the Plugin dashboard
- Download
wp-gistpen.zip
from the WordPress plugins repository. - Navigate to the 'Add New' in the plugins dashboard
- Navigate to the 'Upload' area
- Select
wp-gistpen.zip
from your computer - Click 'Install Now'
- Activate the plugin in the Plugin dashboard
- Download
wp-gistpen.zip
- Extract the
wp-gistpen
directory to your computer - Upload the
wp-gistpen
directory to the/wp-content/plugins/
directory - Activate the plugin in the Plugin dashboard
Your PHP version should be 5.4+, and you must be running WordPress v4.7+. This is because WP-Gistpen relies on the WP-API infrastructure.
Go to the "Pages" screen and create a new, blank page with the name "Gistpens" and click publish. That URL will now display all of your Gistpens. You can link to this page in the menu to direct users to your Gistpens archive page. You can change the name of the page; just make sure the slug of the page is "gistpens".
To add a new Gistpen, go to Gistpens -> Add New, and add your code. You can enable or disable Gist syncing on a a per-Gistpen basis.
You can also create and insert a Gistpen directly into your post/page from the visual editor by clicking the code button. From the pop-up, search for your gistpen, select it, and click insert. Your shortcode will be inserted into the editor.
To highlight a specific line, add highlight=^^
, where ^^ is a line number or range of numbers you want highlighted, like this (via PrismJS documentation):
- A single number refers to the line with that number
- Ranges are denoted by two numbers, separated with a hyphen (-)
- Multiple line numbers or ranges are separated by commas.
- Whitespace is allowed anywhere and will be stripped off.
Examples:
highlight="5"
: The 5th linehighlight="1-5"
: Lines 1 through 5highlight="1,4"
: Line 1 and line 4highlight="1-2,5,9-20"
: Lines 1 through 2, line 5, lines 9 through 20
You can link to a specific line in your Gistpen by linking to #gistpen-{gistpen-slug}.{lines}
. The lines don't need to be highlighted in advance for the link to work, and they will be highlighted when the link is clicked. The {lines}
should match the same format as above.
- Login to GitHub.
- Go to Settings -> Applications.
- Under "Personal access tokens", click "Generate New Token."
- Give it a name, click create
- The default settings work, but make you sure you at least include the
gist
anduser
scopes.
- The default settings work, but make you sure you at least include the
- Copy the generated token.
- Paste it into the settings page.
- ???
- Profit!
Gistpens can be exported en masse. All Gistpens will be synced, only if the Gistpen hasn't been synced yet, but regardless of whether syncing for the Gistpen is enabled. Syncing will then be enabled on the exported Gistpens.
If you do not want this, you can enable/disable Gistpen syncing on a per-Gistpen basis. Just click the checkbox on the Gistpen edit page, and any changes will be reflected on the corresponding Gist on update. If you uncheck that box, future changes will not be reflected on Gist.
To go this, go to the Gistpens settings page and click "Jobs". Next to the the "Export Job", click "Dispatch Job". After the Job is done, check out the log messages to ensure everything exported correctly.
Go to the Gistpents settings page and click "Jobs". Next to the "Import Job", click "Dispatch Job", then check out the log messages to ensure everything was imported correctly.
The Insert Gistpen dialog after you click the pen in the visual editor.
Default theme - How your code will appear in your post.
Twilight theme with line numbers enabled. Check out all the themes at PrismJS.com.
The current options page – first page.
The current options page – second page.
The current options page – third page.
PrismJS-based text editor.