وضاحت
A WordPress plugin to allow you writing on GitHub (or Jekyll site).
Some code for this plugin comes from WordPress GitHub Sync, thanks.
Ever wish you could collaboratively author content for your WordPress site (or expose change history publicly and accept pull requests from your readers)?
Well, now you can! Introducing Writing On GitHub!
Writing On GitHub does three things:
- Allows content publishers to version their content in GitHub
- Allows readers to submit proposed improvements to WordPress-served content via GitHub’s Pull Request model
Writing On GitHub might be able to do some other cool things:
- Allow teams to collaboratively write and edit posts using GitHub (e.g., pull requests, issues, comments)
- Allow you to sync the content of two different WordPress installations via GitHub
- Allow you to stage and preview content before “deploying” to your production server
How it works
The sync action is based on two hooks:
- A per-post sync fired in response to WordPress’s
save_post
hook which pushes content to GitHub - A sync of all changed files triggered by GitHub’s
push
webhook (outbound API call)
انسٽاليشن
Using the WordPress Dashboard
- Navigate to the ‘Add New’ in the plugins dashboard
- Search for ‘Writing On GitHub’
- Click ‘Install Now’
- Activate the plugin on the Plugin dashboard
Uploading in WordPress Dashboard
- Download
writing-on-github.zip
from the WordPress plugins repository. - Navigate to the ‘Add New’ in the plugins dashboard
- Navigate to the ‘Upload’ area
- Select
writing-on-github.zip
from your computer - Click ‘Install Now’
- Activate the plugin in the Plugin dashboard
Using FTP
- Download
writing-on-github.zip
- Extract the
writing-on-github
directory to your computer - Upload the
writing-on-github
directory to the/wp-content/plugins/
directory - Activate the plugin in the Plugin dashboard
Configuring the plugin
- Create a personal oauth token with the
public_repo
scope. If you’d prefer not to use your account, you can create another GitHub account for this. - Configure your GitHub host, repository, secret (defined in the next step), and OAuth Token on the Writing On GitHub settings page within WordPress’s administrative interface. Make sure the repository has an initial commit or the export will fail.
- Create a WebHook within your repository with the provided callback URL and callback secret, using
application/json
as the content type. To set up a webhook on GitHub, head over to the Settings page of your repository, and click on Webhooks & services. After that, click on Add webhook. - Click
Export to GitHub
FAQ
- Markdown Support
-
Writing On GitHub exports all posts as
.md
files for better display on GitHub, but all content is exported and imported as its original HTML. To enable writing, importing, and exporting in Markdown, please install and enable WP-Markdown, and Writing On GitHub will use it to convert your posts to and from Markdown.You can also activate the Markdown module from Jetpack or the standalone JP Markdown to save in Markdown and export that version to GitHub.
- GitHub directory structure
-
. ├── _pages | └── 2007-10-29-some-pages.md ├── _posts | └── 2009-04-26-some-posts.md └── images └── some-images # copy all files (include subdirectory) to wordpress
- Importing from GitHub
-
Writing On GitHub is also capable of importing posts directly from GitHub, without creating them in WordPress before hand. In order to have your post imported into GitHub, add this YAML Frontmatter to the top of your .md document:
--- post_title: 'Post Title' post_name: 'this is post name' post_date: '2018-03-07 15:21:26' layout: post_type_probably_post published: true_or_false author: author_name tags: - tag_a - tag_b categories: - category_a - category_b --- Post goes here.
and fill it out with the data related to the post you’re writing. Save the post and commit it directly to the repository. After the post is added to WordPress, an additional commit will be added to the repository, updating the new post with the new information from the database.
Note that Writing On GitHub will import posts from the
master
branch by default. Once set, do not change it.If Writing On GitHub cannot find the author for a given import, it will fallback to the default user as set on the settings page. Make sure you set this user before you begin importing posts from GitHub. Without it set, Writing On GitHub will default to no user being set for the author as well as unknown-author revisions.
- Contributing
-
Found a bug? Want to take a stab at one of the open issues? We’d love your help!
See the contributing documentation for details.
- Prior Art
جائزا
تعاون ڪندڙ & ڊولپرز
“Writing On GitHub” اوپن سورس سافٽ ويئر آهي. ھيٺين ماڻھن ھن پلگ ان ۾ حصو ورتو آھي.
تعاون ڪندڙواحد: “Writing On GitHub” 1 لوڪل ۾ ترجمو ڪيو ويو آهي. ترجمي ڪندڙن جي مهرباني سندن تعاون لاءِ.
ترجمو ڪريو “Writing On GitHub” توهان جي ٻولي ۾.
ڊولپمينٽ ۾ دلچسپي؟
ڪوڊ براؤز ڪريو، چيڪ ڪريو SVN مخزن، يا رڪنيت حاصل ڪريو ڊولپمينٽ لاگ پاران RSS.
لاگ تبدیل ڪريو
1.11
- Fixed correct the url of files in the images directory
1.10
- Fixed cannot publish post from github in _draffts
- Fixed cannot delete post from github
- Change github path to /_posts/$year/$postname
1.9
- Fixed webhook error on apache server
1.8
- Apply post_date from github
- Friendly error message when validate webhook event
- Friendly error message when can not import
1.7
- Add an option to force import from github
1.6.1
- Compatible with wordpress 4.8.1
- Add index.php
1.6
- Add Settings link on plugins page
- Add an option of “Don’t export content”
- Fixed cannot auto export to github when change frontmatter from github
- Don’t export to github when has not changed
- Reduce memory when import from github
- Refactor the code to enhance stability
1.5.1
- Compatible with PHP5.0
1.5
- Add an option to ignore the author
- Add an option to force export to github
- Change permalink to link in frontmatter
- Change export github commit message
1.4
- Ignore custom post meta
- copy image files from /images/* to wp-content/uploads/writing-on-github/images/*
1.3
- Fixed backslash loss
1.2
- Add post_name to post meta
- Add ignore metas to setting
1.1
- Transfer ownership
1.0
- Initial version