• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

magnetikonline/github-markdown-render: Display Markdown formatted documents on y ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

magnetikonline/github-markdown-render

开源软件地址:

https://github.com/magnetikonline/github-markdown-render

开源编程语言:

PHP 93.3%

开源软件介绍:

GitHub Markdown render

Display Markdown formatted documents on your local development web server using GitHub's Markdown Rendering API and CSS to mimic the visual display on GitHub itself.

Handy for authoring/previewing README.md files (or any Markdown for that matter) in project repositories, hopefully avoiding noisy git push actions in commit logs due to excessive typos/errors.

Note: this is intended for local development only, probably not a good idea for production use due to GitHub API rate limits per user.

Requires

  • PHP 5.4+
  • PHP cURL extension - more than likely already part of your PHP install/compile.
  • Nginx or Apache URL rewrite support.

Usage

Markdown files are accessible from a local web server and returned in plain text, for example:

http://localhost/projects/ghmarkdownrender/README.md
http://localhost/projects/thummer/README.md
http://localhost/projects/unrarallthefiles/README.md
http://localhost/projects/webserverinstall.ubuntu12.04/install.md

To view rendered Markdown, request same URIs with a querystring switch:

http://localhost/projects/ghmarkdownrender/README.md?ghmd
http://localhost/projects/thummer/README.md?ghmd
http://localhost/projects/unrarallthefiles/README.md?ghmd
http://localhost/projects/webserverinstall.ubuntu12.04/install.md?ghmd

Rendered result is cached against the last modification time of each Markdown document to reduce repeated GitHub API calls for identical source content.

Install

Configure index.php

Generate a new GitHub OAuth personal access token using either:

Note down the token generated.

Update the following constants within index.php in the GitHubMarkdownRender class:

Setting Description
GITHUB_PERSONAL_ACCESS_TOKEN Your generated GitHub personal access token. Anonymous GitHub API calls are limited to 60 per hour, providing user credentials ramps this up to a more usable 5000 requests per hour.
DOCUMENT_ROOT Web server document root location on the file system. Assumes you are serving up all your project(s) directories under a default virtual host.

Setup URL rewrite rules

  • Configure a URL rewrite for your default virtual host so all requests to /local/path/*.md?ghmd are rewritten to /path/to/ghmarkdownrender/index.php.
  • Refer to the supplied rewrite.nginx.conf & rewrite.apache.conf for examples.

Note:

  • You may wish to have requested raw Markdown files served up with a MIME type such as text/plain for convenience.
    • Nginx by default serves up unknown file types based on extension as application/octet-stream, forcing a browser download - see /etc/nginx/mime.types within your Nginx installation and modify to suit.
  • Haven't tested rewrite.apache.conf - it should do the trick, would appreciate a pull-request if it needs fixing.

Test

You should now be able to call a Markdown document with a querystring of ?ghmd to receive a familiar GitHub style Markdown display. The page footer will also display the total/available API rate limits, or if rendering was returned from cache.

CSS style issues

Markdown display CSS has been lifted (deliberately) from GitHub.com. It's quite possible/likely there are some CSS styles missing to make this complete.

If anything missing is noted with your own markdown documents, it would be great to get any source examples or pull requests (add your example(s) to test.md) to help make things complete.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap