Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gitium/gitium-webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
if ( $git->is_dirty() && $git->add() > 0 ) {
$commits[] = $git->commit( $commitmsg ) or trigger_error( 'Could not commit local changes!', E_USER_ERROR );
}
gitium_merge_and_push( $commits ) or trigger_error( 'Failed merge & push: ' . serialize( $git->get_last_error() ), E_USER_ERROR );
gitium_merge_and_push( $commits ) or trigger_error( 'Failed merge & push: ' . esc_html(serialize( $git->get_last_error() ) ), E_USER_ERROR );

wp_die( $commitmsg , 'Pull done!', array( 'response' => 200 ) );
wp_die( esc_html($commitmsg) , 'Pull done!', array( 'response' => 200 ) );
else :
wp_die( 'Cheating uh?', 'Cheating uh?', array( 'response' => 403 ) );
endif;
74 changes: 37 additions & 37 deletions gitium/inc/class-gitium-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,85 +29,85 @@ public function __construct( $hook, $help = 'gitium' ) {

private function general() {
$screen = get_current_screen();
$screen->add_help_tab( array( 'id' => 'gitium', 'title' => __( 'Gitium', 'gitium' ), 'callback' => array( $this, 'gitium' ) ) );
$screen->add_help_tab( array( 'id' => 'faq', 'title' => __( 'F.A.Q.', 'gitium' ), 'callback' => array( $this, 'faq' ) ) );
$screen->add_help_tab( array( 'id' => 'requirements', 'title' => __( 'Requirements', 'gitium' ), 'callback' => array( $this, 'requirements_callback' ) ) );
$screen->add_help_tab( array( 'id' => 'gitium', 'title' => 'Gitium', 'callback' => array( $this, 'gitium' ) ) );
$screen->add_help_tab( array( 'id' => 'faq', 'title' => 'F.A.Q.', 'callback' => array( $this, 'faq' ) ) );
$screen->add_help_tab( array( 'id' => 'requirements', 'title' => 'Requirements', 'callback' => array( $this, 'requirements_callback' ) ) );
$screen->set_help_sidebar( '<div style="width:auto; height:auto; float:right; padding-right:28px; padding-top:15px"><img src="' . plugins_url( 'img/gitium.svg', dirname( __FILE__ ) ) . '" width="96"></div>' );
}

public function gitium() {
echo '<p>' . __( 'Gitium enables continuous deployment for WordPress integrating with tools such as Github, Bitbucket or Travis-CI. Plugin and theme updates, installs and removals are automatically versioned.', 'gitium' ) . '</p>';
echo '<p>' . __( 'Ninja code edits from the WordPress editor are also tracked into version control. Gitium is designed for sane development environments.', 'gitium' ) . '</p>';
echo '<p>' . __( 'Staging and production can follow different branches of the same repository. You can deploy code simply trough git push.', 'gitium' ) . '</p>';
echo '<p>' . __( 'Gitium requires <code>git</code> command line tool minimum version 1.7 installed on the server and <code>proc_open</code> PHP function enabled.', 'gitium' ) . '</p>';
echo '<p>Gitium enables continuous deployment for WordPress integrating with tools such as Github, Bitbucket or Travis-CI. Plugin and theme updates, installs and removals are automatically versioned.</p>';
echo '<p>Ninja code edits from the WordPress editor are also tracked into version control. Gitium is designed for sane development environments.</p>';
echo '<p>Staging and production can follow different branches of the same repository. You can deploy code simply trough git push.</p>';
echo '<p>Gitium requires <code>git</code> command line tool minimum version 1.7 installed on the server and <code>proc_open</code> PHP function enabled.</p>';
}

public function faq() {
echo '<p><strong>' . __( 'Could not connect to remote repository?', 'gitium' ) . '</strong><br />'. __( 'If you encounter this kind of error you can try to fix it by setting the proper username of the .git directory.', 'gitium' ) . '<br />' . __( 'Example', 'gitium' ) .': <code>chown -R www-data:www-data .git</code></p>';
echo '<p><strong>' . __( 'Is this plugin considered stable?', 'gitium' ) . '</strong><br />'. __( 'Right now this plugin is considered alpha quality and should be used in production environments only by adventurous kinds.', 'gitium' ) . '</p>';
echo '<p><strong>' . __( 'What happens in case of conflicts?', 'gitium' ) . '</strong><br />'. __( 'The behavior in case of conflicts is to overwrite the changes on the origin repository with the local changes (ie. local modifications take precedence over remote ones).', 'gitium' ) . '</p>';
echo '<p><strong>' . __( 'How to deploy automatically after a push?', 'gitium' ) . '</strong><br />'. __( 'You can ping the webhook url after a push to automatically deploy the new code. The webhook url can be found under Code menu. This url plays well with Github or Bitbucket webhooks.', 'gitium' ) . '</p>';
echo '<p><strong>' . __( 'Does it works on multi site setups?', 'gitium' ) . '</strong><br />'. __( 'Gitium is not supporting multisite setups at the moment.', 'gitium' ) . '</p>';
echo '<p><strong>' . __( 'How does gitium handle submodules?', 'gitium' ) . '</strong><br />'. __( 'Currently submodules are not supported.', 'gitium' ) . '</p>';
echo '<p><strong>Could not connect to remote repository?</strong><br/>If you encounter this kind of error you can try to fix it by setting the proper username of the .git directory.<br />Example: <code>chown -R www-data:www-data .git</code></p>';
echo '<p><strong>Is this plugin considered stable?</strong><br />Right now this plugin is considered alpha quality and should be used in production environments only by adventurous kinds.</p>';
echo '<p><strong>What happens in case of conflicts?</strong><br />The behavior in case of conflicts is to overwrite the changes on the origin repository with the local changes (ie. local modifications take precedence over remote ones).</p>';
echo '<p><strong>How to deploy automatically after a push?</strong><br />You can ping the webhook url after a push to automatically deploy the new code. The webhook url can be found under Code menu. This url plays well with Github or Bitbucket webhooks.</p>';
echo '<p><strong>Does it works on multi site setups?</strong><br />Gitium is not supporting multisite setups at the moment.</p>';
echo '<p><strong>How does gitium handle submodules?</strong><br />Currently submodules are not supported.</p>';
}

public function requirements_callback() {
echo '<p>' . __( 'Gitium requires:', 'gitium' ) . '</p>';
echo '<p>' . __( 'the function proc_open available', 'gitium' ) . '</p>';
echo '<p>' . __( 'can exec the file inc/ssh-git', 'gitium' ) . '</p>';
echo '<p>Gitium requires:</p>';
echo '<p>the function proc_open available</p>';
echo '<p>can exec the file inc/ssh-git</p>';

printf( '<p>' . __( 'git version >= %s', 'gitium' ) . '</p>', GITIUM_MIN_GIT_VER );
printf( '<p>' . __( 'PHP version >= %s', 'gitium' ) . '</p>', GITIUM_MIN_PHP_VER );
printf( '<p>git version >= %s</p>', esc_html( GITIUM_MIN_GIT_VER ) );
printf( '<p>PHP version >= %s</p>', esc_html( GITIUM_MIN_PHP_VER ) );
}

public function configuration() {
$screen = get_current_screen();
$screen->add_help_tab( array( 'id' => 'configuration', 'title' => __( 'Configuration', 'gitium' ), 'callback' => array( $this, 'configuration_callback' ) ) );
$screen->add_help_tab( array( 'id' => 'configuration', 'title' => 'Configuration', 'callback' => array( $this, 'configuration_callback' ) ) );
$this->general();
}

public function configuration_callback() {
echo '<p><strong>' . __( 'Configuration step 1', 'gitium' ) . '</strong><br />' . __( 'In this step you must specify the <code>Remote URL</code>. This URL represents the link between the git sistem and your site.', 'gitium' ) . '</p>';
echo '<p>' . __( 'You can get this URL from your Git repository and it looks like this:', 'gitium' ) . '</p>';
echo '<p>' . __( 'github.com -> git@github.com:user/example.git', 'gitium' ) . '</p>';
echo '<p>' . __( 'bitbucket.org -> git@bitbucket.org:user/glowing-happiness.git', 'gitium' ) . '</p>';
echo '<p>' . __( 'To go to the next step, fill the <code>Remote URL</code> and then press the <code>Fetch</code> button.', 'gitium' ) . '</p>';
echo '<p><strong>' . __( 'Configuration step 2', 'gitium' ) . '</strong><br />' . __( 'In this step you must select the <code>branch</code> you want to follow.', 'gitium' ) . '</p>';
echo '<p>' . __( 'Only this branch will have all of your code modifications.', 'gitium' ) . '</p>';
echo '<p>' . __( 'When you push the button <code>Merge & Push</code>, all code(plugins & themes) will be pushed on the git repository.', 'gitium' ) . '</p>';
echo '<p><strong>Configuration step 1</strong><br />In this step you must specify the <code>Remote URL</code>. This URL represents the link between the git sistem and your site.</p>';
echo '<p>You can get this URL from your Git repository and it looks like this:</p>';
echo '<p>github.com -> git@github.com:user/example.git</p>';
echo '<p>bitbucket.org -> git@bitbucket.org:user/glowing-happiness.git</p>';
echo '<p>To go to the next step, fill the <code>Remote URL</code> and then press the <code>Fetch</code> button.</p>';
echo '<p><strong>Configuration step 2</strong><br />In this step you must select the <code>branch</code> you want to follow.</p>';
echo '<p>Only this branch will have all of your code modifications.</p>';
echo '<p>When you push the button <code>Merge & Push</code>, all code(plugins & themes) will be pushed on the git repository.</p>';
}

public function status() {
$screen = get_current_screen();
$screen->add_help_tab( array( 'id' => 'status', 'title' => __( 'Status', 'gitium' ), 'callback' => array( $this, 'status_callback' ) ) );
$screen->add_help_tab( array( 'id' => 'status', 'title' => 'Status', 'callback' => array( $this, 'status_callback' ) ) );
$this->general();
}

public function status_callback() {
echo '<p>' . __( 'On status page you can see what files are modified, and you can commit the changes to git.', 'gitium' ) . '</p>';
echo '<p>On status page you can see what files are modified, and you can commit the changes to git.</p>';
}

public function commits() {
$screen = get_current_screen();
$screen->add_help_tab( array( 'id' => 'commits', 'title' => __( 'Commits', 'gitium' ), 'callback' => array( $this, 'commits_callback' ) ) );
$screen->add_help_tab( array( 'id' => 'commits', 'title' => 'Commits', 'callback' => array( $this, 'commits_callback' ) ) );
$this->general();
}

public function commits_callback() {
echo '<p>' . __( 'You may be wondering what is the difference between author and committer.', 'gitium' ) . '</p>';
echo '<p>' . __( 'The <code>author</code> is the person who originally wrote the patch, whereas the <code>committer</code> is the person who last applied the patch.', 'gitium' ) . '</p>';
echo '<p>' . __( 'So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer.', 'gitium' ) . '</p>';
echo '<p>You may be wondering what is the difference between author and committer.</p>';
echo '<p>The <code>author</code> is the person who originally wrote the patch, whereas the <code>committer</code> is the person who last applied the patch.</p>';
echo '<p>So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer.</p>';
}

public function settings() {
$screen = get_current_screen();
$screen->add_help_tab( array( 'id' => 'settings', 'title' => __( 'Settings', 'gitium' ), 'callback' => array( $this, 'settings_callback' ) ) );
$screen->add_help_tab( array( 'id' => 'settings', 'title' => 'Settings', 'callback' => array( $this, 'settings_callback' ) ) );
$this->general();
}

public function settings_callback() {
echo '<p>' . __( 'Each line from the gitignore file specifies a pattern.', 'gitium' ) . '</p>';
echo '<p>' . __( 'When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome)', 'gitium' ) . '</p>';
echo '<p>' . sprintf( __( 'Read more on %s', 'gitium' ), '<a href="http://git-scm.com/docs/gitignore" target="_blank">git documentation</a>' ) . '</p>';
echo '<p>Each line from the gitignore file specifies a pattern.</p>';
echo '<p>When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome)</p>';
echo '<p>' . sprintf( 'Read more on %s', '<a href="http://git-scm.com/docs/gitignore" target="_blank">git documentation</a>' ) . '</p>';
}
}
6 changes: 3 additions & 3 deletions gitium/inc/class-gitium-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public function disconnect_repository() {
check_admin_referer( 'gitium-admin' );
gitium_uninstall_hook();
if ( ! $this->git->remove_remote() ) {
$this->redirect( __('Could not remove remote.', 'gitium') );
$this->redirect( 'Could not remove remote.');
}
$this->success_redirect( __('You are now disconnected from the repository. New key pair generated.', 'gitium') );
$this->success_redirect( 'You are now disconnected from the repository. New key pair generated.' );
}

public function show_message() {
Expand All @@ -96,7 +96,7 @@ protected function show_disconnect_repository_button() {
<?php
wp_nonce_field( 'gitium-admin' );
?>
<input type="submit" name="GitiumSubmitDisconnectRepository" value='<?php _e( 'Disconnect from repo', 'gitium' ); ?>' class="button secondary" onclick="return confirm('<?php _e( 'Are you sure you want to disconnect from the remote repository?', 'gitium' ); ?>')"/>&nbsp;
<input type="submit" name="GitiumSubmitDisconnectRepository" value="<?php echo 'Disconnect from repo'; ?>" class="button secondary" onclick="return confirm('<?php echo 'Are you sure you want to disconnect from the remote repository?'; ?>')"/>&nbsp;
</form>
<?php
}
Expand Down
2 changes: 1 addition & 1 deletion gitium/inc/class-gitium-requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function admin_notices() {

foreach ( $this->req as $key => $value ) {
if ( false === $value ) {
echo "<div class='error-nag error'><p>Gitium Requirement: {$this->msg[$key]}</p></div>";
echo "<div class='error-nag error'><p>Gitium Requirement: {" . esc_html($this->msg[$key]) . "}</p></div>";
}
}
}
Expand Down
94 changes: 61 additions & 33 deletions gitium/inc/class-gitium-submenu-commits.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct() {
public function admin_menu() {
$submenu_hook = add_submenu_page(
$this->menu_slug,
__( 'Git Commits', 'gitium' ),
__( 'Commits', 'gitium' ),
'Git Commits',
'Commits',
GITIUM_MANAGE_OPTIONS_CAPABILITY,
$this->submenu_slug,
array( $this, 'page' )
Expand All @@ -44,7 +44,7 @@ public function table_head() {
?>
<thead>
<tr>
<th scope="col"><?php _e( 'Commits', 'gitium' ); ?></th>
<th scope="col"><?php echo 'Commits'; ?></th>
<th scope="col"></th>
</tr>
</thead>
Expand All @@ -64,37 +64,65 @@ public function table_start_row() {
public function page() {
?>
<div class="wrap">
<h2><?php printf( __( 'Last %s commits', 'gitium' ), GITIUM_LAST_COMMITS ); ?></h2>
<table class="wp-list-table widefat plugins">
<?php $this->table_head(); ?>
<tbody>
<?php
foreach ( $this->git->get_last_commits( GITIUM_LAST_COMMITS ) as $commit_id => $data ) {
unset( $committer_name );
extract( $data );
if ( isset( $committer_name ) ) {
$committer = "<span title='$committer_email'> -> $committer_name " . sprintf( __( 'committed %s ago', 'gitium' ), human_time_diff( strtotime( $committer_date ) ) ) . '</span>';
$committers_avatar = '<div style="position:absolute; left:30px; border: 1px solid white; background:white; height:17px; top:30px; border-radius:2px">' . get_avatar( $committer_email, 16 ) . '</div>';
} else {
$committer = '';
$committers_avatar = '';
}
$this->table_start_row();
?>
<td style="position:relative">
<div style="float:left; width:auto; height:auto; padding-left:2px; padding-right:5px; padding-top:2px; margin-right:5px; border-radius:2px"><?php echo get_avatar( $author_email, 32 ); ?></div>
<?php echo $committers_avatar; ?>
<div style="float:left; width:auto; height:auto;"><strong><?php echo esc_html( $subject ); ?></strong><br />
<span title="<?php echo esc_attr( $author_email ); ?>"><?php echo esc_html( $author_name ) . ' ' . sprintf( __( 'authored %s ago', 'gitium' ), human_time_diff( strtotime( $author_date ) ) ); ?></span><?php echo $committer; ?></div>
</td>
<td><p style="padding-top:8px"><?php echo $commit_id; ?></p></td>
<?php
$this->table_end_row();
}
?>
</tbody>
</table>
<h2><?php printf( 'Last %s commits', esc_html( GITIUM_LAST_COMMITS ) ); ?></h2>
<table class="wp-list-table widefat plugins">
<?php $this->table_head(); ?>
<tbody>
<?php
foreach ( $this->git->get_last_commits( GITIUM_LAST_COMMITS ) as $commit_id => $data ) {
unset( $committer_name );
extract( $data );

// Prepare committer HTML
if ( isset( $committer_name ) ) {
$committer = sprintf(
'<span title="%s"> -> %s %s</span>',
esc_attr( $committer_email ),
esc_html( $committer_name ),
sprintf( esc_html( 'committed %s ago'), human_time_diff( strtotime( $committer_date ) ) )
);

$committers_avatar = sprintf(
'<div style="position:absolute; left:30px; top:30px; border:1px solid white; background:white; height:17px; border-radius:2px;">%s</div>',
get_avatar( $committer_email, 16 )
);
} else {
$committer = '';
$committers_avatar = '';
}

$this->table_start_row();
?>
<td style="position:relative;">
<div style="float:left; width:auto; height:auto; padding:2px 5px 0 2px; margin-right:5px; border-radius:2px;">
<?php echo get_avatar( $author_email, 32 ); ?>
</div>
<?php echo wp_kses_post( $committers_avatar ); ?>
<div style="float:left; width:auto; height:auto;">
<strong><?php echo esc_html( $subject ); ?></strong><br />
<span title="<?php echo esc_attr( $author_email ); ?>">
<?php
echo esc_html( $author_name ) . ' ';
printf(
esc_html( 'authored %s ago'),
esc_html( human_time_diff( strtotime( $author_date ) ) )
);
?>
</span>
<?php echo wp_kses_post( $committer ); ?>
</div>
</td>
<td>
<p style="padding-top:8px;"><?php echo esc_html( $commit_id ); ?></p>
</td>
<?php
$this->table_end_row();
}
?>
</tbody>
</table>
</div>
<?php
}

}
Loading