Skip to content

Commit

Permalink
v1.8 changes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
vaakash committed Nov 12, 2023
1 parent 4a24e60 commit 891def4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 38 deletions.
24 changes: 12 additions & 12 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ public static function edit_repo( $action = 'edit' ){
echo '<tbody>';

echo '<tr>';
echo '<td style="width: 300px">Github username/owner</td>';
echo '<td style="width: 300px">GitHub username/owner</td>';
echo '<td><input type="text" name="giw_username" value="' . esc_attr( $values[ 'username' ] ) . '" required="required" />';
echo '<p class="description">The username of the Github repository</p>';
echo '<p class="description">The username of the GitHub repository</p>';
echo '</td>';
echo '</tr>';

echo '<tr>';
echo '<td>Repository name</td>';
echo '<td><input type="text" name="giw_repository" value="' . esc_attr( $values[ 'repository' ] ) . '" required="required" />';
echo '<p class="description">The name of the Github repository to pull and publish posts from</p>';
echo '<p class="description">The name of the GitHub repository to pull and publish posts from</p>';
echo '</td>';
echo '</tr>';

Expand Down Expand Up @@ -247,7 +247,7 @@ public static function edit_repo( $action = 'edit' ){
'teeny' => true,
'textarea_rows' => 4
));
echo '<p class="description">The template of the post content. Use any text, HTML, shortcode you would like to be added to all the posts when they are published. Supported placeholder <code>%%content%%</code> (The HTML of the pulled post). Use shortcode <code>[giw_edit_link]</code> to insert a link of the source Github file to edit and collaborate. You might need to "Pull all the files" to update the post if the template is changed.</p>';
echo '<p class="description">The template of the post content. Use any text, HTML, shortcode you would like to be added to all the posts when they are published. Supported placeholder <code>%%content%%</code> (The HTML of the pulled post). Use shortcode <code>[giw_edit_link]</code> to insert a link of the source GitHub file to edit and collaborate. You might need to "Pull all the files" to update the post if the template is changed.</p>';
echo '</td>';
echo '</tr>';

Expand Down Expand Up @@ -302,7 +302,7 @@ public static function pull_posts(){

$id = $g[ 'id' ];

echo '<h2>Pull posts from Github for [' . esc_html( $id ) . ']</h2>';
echo '<h2>Pull posts from GitHub for [' . esc_html( $id ) . ']</h2>';

echo '<table class="widefat striped">';
echo '<tbody>
Expand Down Expand Up @@ -375,22 +375,22 @@ public static function general_settings(){
echo '<tr>';
echo '<td style="width: 200px">Webhook secret</td>';
echo '<td><input type="password" class="webhook_secret" name="giw_webhook_secret" value="' . esc_attr( $values[ 'webhook_secret' ] ) . '" autocomplete="new-password" /> &nbsp;<button class="button">Toggle view</button>';
echo '<p class="description">Go to Github repository settings --> Webhook and add a webhook for the payload URL <code>' . esc_html( rest_url( '/giw/v1/publish' ) ) . '</code> if you would like to automatically publish the changes whenever repository is updated.</p>';
echo '<p class="description">Go to GitHub repository settings --> Webhook and add a webhook for the payload URL <code>' . esc_html( rest_url( '/giw/v1/publish' ) ) . '</code> if you would like to automatically publish the changes whenever repository is updated.</p>';
echo '<p class="description">Select content-type as <code>application/json</code> and enter a secret text. Provide the same secret text in the above field. Select "Just the push event" for the webhook trigger. Make sure all the repositories you would like to automatically update have the same payload URL and the secret.</p>';
echo '</td>';
echo '</tr>';

echo '<tr><td colspan="2"><h4>Authentication</h4></td></tr>';

echo '<tr>';
echo '<td>Github Username</td>';
echo '<td>GitHub Username</td>';
echo '<td><input type="text" name="giw_github_username" value="' . esc_attr( $values[ 'github_username' ] ) . '" />';
echo '<p class="description">Your Github username for authenticating API calls.</p></td>';
echo '<p class="description">Your GitHub username for authenticating API calls.</p></td>';
echo '</tr>';

echo '<tr>';
echo '<td>Github Access token</td>';
echo '<td><input type="text" name="giw_github_access_token" value="' . esc_attr( $values[ 'github_access_token' ] ) . '" />';
echo '<td>GitHub Access token</td>';
echo '<td><input type="password" name="giw_github_access_token" value="' . esc_attr( $values[ 'github_access_token' ] ) . '" /> &nbsp;<button class="button">Toggle view</button>';
echo '<p class="description">Create an access token by following <a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-token" target="_blank">the instructions here.</a> Select <code>repo -> public_repo</code> under scopes and generate a token.
</p></td>';
echo '</tr>';
Expand Down Expand Up @@ -499,9 +499,9 @@ public static function sidebar(){
echo '<a class="cta_link" href="https://www.aakashweb.com/docs/git-it-write/" target="_blank">See plugin documentation <span class="dashicons dashicons-arrow-right-alt"></span></a>';
echo '</div>';

echo '<p><a href="https://github.com/vaakash/git-it-write" class="button side_btn" target="_blank"><span class="dashicons dashicons-editor-code"></span> Contribute on Github</a></p>';
echo '<p><a href="https://github.com/vaakash/git-it-write" class="button side_btn" target="_blank"><span class="dashicons dashicons-editor-code"></span> Contribute on GitHub</a></p>';

echo '<p><a href="https://twitter.com/intent/tweet?hashtags=wordpress,markdown,github&related=aakashweb&text=Check%20it%20out%20-%20%22Git%20it%20Write%22%20a%20new%20WordPress%20plugin%20to%20publish%20posts%20from%20Github%20using%20markdown%20files%20and%20allow%20people%20to%20collaborate%20%E2%9C%8D%20https://wordpress.org/plugins/git-it-write/" class="button side_btn" target="_blank"><span class="dashicons dashicons-share"></span> Share with friends</a></p>';
echo '<p><a href="https://twitter.com/intent/tweet?hashtags=wordpress,markdown,github&related=aakashweb&text=Check%20it%20out%20-%20%22Git%20it%20Write%22%20a%20new%20WordPress%20plugin%20to%20publish%20posts%20from%20GitHub%20using%20markdown%20files%20and%20allow%20people%20to%20collaborate%20%E2%9C%8D%20https://wordpress.org/plugins/git-it-write/" class="button side_btn" target="_blank"><span class="dashicons dashicons-share"></span> Share with friends</a></p>';

}

Expand Down
8 changes: 4 additions & 4 deletions admin/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ table.widefat td {
margin-bottom: 15px;
background-size: 95px;
background-color: #fff;
border: 1px solid #dfdfdf;
border: 1px solid #c3c4c7;
}
.side_card h2 {
margin: -20px -20px 20px -20px;
padding: 12.5px 15px;
border-bottom: 1px solid #dfdfdf;
border-bottom: 1px solid #c3c4c7;
font-size: 1.2em;
}
.side_card h2 .dashicons {
Expand Down Expand Up @@ -147,12 +147,12 @@ table.widefat td {
margin-bottom: 0;
}
.twitter_btn.button{
background: #1b95e0;
background: #000;
color: #fff;
border-color: transparent;
}
.facebook_btn.button{
background: #4080ff;
background: #0866ff;
color: #fff;
border-color: transparent;
}
Expand Down
11 changes: 6 additions & 5 deletions admin/js/script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
(function($){
$(document).ready(function(){
var $wh_secret = $(".webhook_secret");
$wh_secret.next().click(function(e){
var $secret_input = $('input[type="password"]');
$secret_input.next().click(function(e){
e.preventDefault();
if($wh_secret.attr("type") == "text"){
$wh_secret.attr("type", "password");
var $the_input = $(this).prev();
if($the_input.attr('type') == 'text'){
$the_input.attr('type', 'password');
}else{
$wh_secret.attr("type", "text");
$the_input.attr('type', 'text');
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions git-it-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Description: Publish markdown files present in a Github repository as posts to WordPress automatically
Author: Aakash Chakravarthy
Author URI: https://www.aakashweb.com/
Version: 1.7
Version: 1.8
*/

define( 'GIW_VERSION', '1.7' );
define( 'GIW_VERSION', '1.8' );
define( 'GIW_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
define( 'GIW_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );

Expand Down
1 change: 1 addition & 0 deletions includes/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function get( $url ){
$response = wp_remote_get( $url, $args );

if( is_wp_error( $response ) ) {
GIW_Utils::log( 'Error: ' . $response->get_error_message() );
return false;
}

Expand Down
36 changes: 21 additions & 15 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Git it Write - Write posts from Github
# Git it Write - Write posts from GitHub
Contributors: vaakash
Author URI: https://www.aakashweb.com/
Plugin URI: https://www.aakashweb.com/wordpress-plugins/git-it-write/
Expand All @@ -10,21 +10,21 @@ Requires at least: 4.4
Tested up to: 6.4.1
Stable tag: 1.8

Publish markdown files present in a Github repository as posts to WordPress automatically
Publish markdown files present in a GitHub repository as posts to WordPress automatically



## Description

Git it Write allows to publish the markdown files present in a Github repository to your WordPress site. So with this plugin, whenever the files are added, updated in the repository the WordPress post will be added, updated accordingly.
Git it Write allows to publish the markdown files present in a GitHub repository to your WordPress site. So with this plugin, whenever the files are added, updated in the repository the WordPress post will be added, updated accordingly.

This plugin is inspired from static site generators like `Jekyll`, `Next.js`, `Gatsby.js` on how content is written is markdown. This is a similar idea for WordPress where markdown files are parsed from Github and published as posts.
This plugin is inspired from static site generators like `Jekyll`, `Next.js`, `Gatsby.js` on how content is written is markdown. This is a similar idea for WordPress where markdown files are parsed from GitHub and published as posts.

👓 **Live example:** [Source github repository](https://github.com/vaakash/aakash-web) (`/docs/` folder) to [Posts published](https://www.aakashweb.com/docs/)

⚡ **Getting started:** [Get started](https://www.aakashweb.com/docs/git-it-write/getting-started/) with Git it write. Learn how to write `.md` files and publish posts on WordPress.

This allows people to collaborate with the post, share edits and suggestions in Github which when pulled the WordPress post will be updated automatically.
This allows people to collaborate with the post, share edits and suggestions in GitHub which when pulled the WordPress post will be updated automatically.

If a repository has files in the below structure,

Expand All @@ -43,10 +43,10 @@ Then below posts will be created like below (if permalinks are configured and th

### 🎲 What is the use of this plugin ?

* Publish posts using the files in your Github repository.
* Publish posts using the files in your GitHub repository.
* Write your posts in Markdown format.
* Write your posts on your desktop application (Notepad++, Sublime Text, Visual studio code).
* Collaborate, involve communities on the files in Github and publish them on WordPress.
* Collaborate, involve communities on the files in GitHub and publish them on WordPress.
* All the advantages of Git and it's version management system.

### 🚀 Some use cases
Expand All @@ -70,7 +70,7 @@ Then below posts will be created like below (if permalinks are configured and th
### ℹ Note

* Only Markdown files will be pulled and published right now
* Posts won't be deleted when it's source file is deleted on Github.
* Posts won't be deleted when it's source file is deleted on GitHub.
* It is preferred to have a permalink structure.
* It is preferred to select a post type which supports hierarchy.
* Images have to present only in `_images` folder in the repository root. Markdown files have to relatively use them in the file.
Expand All @@ -81,7 +81,7 @@ It is recommended that a permalink structure is enabled in the WordPress site so

### 🏃‍♂️ Using the plugin

1. Have a Github repository where all the source files (markdown files) are maintained (organized in folders if needed the exact structure)
1. Have a GitHub repository where all the source files (markdown files) are maintained (organized in folders if needed the exact structure)
1. In the plugin settings page, click add a new repository.
1. Enter the details of the repository to pull the posts from and under what post type to publish them.
1. Save the settings
Expand All @@ -93,7 +93,7 @@ It is recommended that a permalink structure is enabled in the WordPress site so
* [Documentation](https://www.aakashweb.com/docs/git-it-write/)
* [Support forum/Report bugs](https://www.aakashweb.com/forum/)
* [Donate](https://www.paypal.me/vaakash/)
* [Contribute on Github](https://github.com/vaakash/git-it-write)
* [Contribute on GitHub](https://github.com/vaakash/git-it-write)


## Installation
Expand All @@ -108,9 +108,9 @@ It is recommended that a permalink structure is enabled in the WordPress site so

Please visit the [plugin documentation page](https://www.aakashweb.com/docs/git-it-write/) for complete list of FAQs.

### When a post is edited in WordPress will that update the file in the Github repository ?
### When a post is edited in WordPress will that update the file in the GitHub repository ?

No. This plugin won't sync post content. It is a one way update. Only changes made to the Github repository will update the posts and not otherwise.
No. This plugin won't sync post content. It is a one way update. Only changes made to the GitHub repository will update the posts and not otherwise.

### What all files in the repository will be published ?

Expand All @@ -131,8 +131,8 @@ Yes, if you want to pull posts from a folder in a repository then you can specif

## Screenshots

1. Your files in a Github repository
2. Posts pulled and published from Github.
1. Your files in a GitHub repository
2. Posts pulled and published from GitHub.
3. Content of the published post.
4. Published post.
5. Plugin admin page.
Expand All @@ -142,6 +142,12 @@ Yes, if you want to pull posts from a folder in a repository then you can specif

## Changelog

### 1.8
* New: Error message during HTTP get/post is now logged.
* Fix: Double quotes in WordPress shortcodes are escaped.
* Fix: GitHub access token field in admin form is converted to a password field.
* Fix: Typos in readme and admin page.

### 1.7
* New: Images (`_images`) can be now organized in folders.
* New: Featured image can now be set to posts.
Expand All @@ -159,7 +165,7 @@ Yes, if you want to pull posts from a folder in a repository then you can specif
* Fix: Enhancements to data escaping in the admin page.

### 1.4
* Fix: Repository not found issue by adding Github authentication.
* Fix: Repository not found issue by adding GitHub authentication.
* Fix: Duplicate posts when filename has special characters.
* Fix: PHP warning when directory has no index.md file.

Expand Down

0 comments on commit 891def4

Please sign in to comment.