GitHub Pages (ghpages) is a Drupal 7 module allowing users to add their content to a shared "gh-pages" branch, which can then be pushed to and hosted on GitHub.

Initially designed to allow seamless cloud-hosted visualizations for the forthcoming VizCloud Drupal distribution, it supplies a bit of functionality that isn't available anywhere else in the Drupal module ecosystem. As such, this makes it a good candidate to be released as a module unto itself.

There are two major reasons why saving nodes on GitHub is cool:

  • With VizCloud, this means a user can generate a complex Views query to feed into a JavaScript-based interactive graphic, save that as a static version, and then serve that effortlessly without having to worry about optimizing a Drupal installation to accommodate high levels of traffic. Creating interactive graphics that can cope with excessive levels of traffic is a constant challenge for data journalists — this is one way around it.
  • It provides a way for a basic Drupal installation to be used as an offline content creation and management tool (Somewhat like the FrontPages and Dreamweavers of yore) — users create content using a local installation, which is then hosted independently on GitHub Pages. This may be preferable in some situations where a user wants to leverage Drupal's advanced tools (Views, Panels, etc.) for a particular task, even if there's no possibility of that Drupal installation ever being used to host content itself (I.e., it's behind a corporate firewall).

Usage is simple: an admin configures a central repository, which gets added to every time a user with appropriate permissions clicks the big "Push to GitHub" button on the edit node page.

Some code is based off SaveToFTP -- http://drupal.org/project/savetoftp

Upcoming features

  • User repos -- push to the shared central repo, or define a personal GitHub repo to push to.
  • Integration with GitHub Connect.

Project Page: http://drupal.org/sandbox/aendrew/1914226
PAReview.sh results: http://ventral.org/pareview/httpgitdrupalorgsandboxaendrew1914226git
git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/aendrew/1914226.git github_pages

Many thanks!

Reviewed proposals

http://drupal.org/node/1857646#comment-7056904
http://drupal.org/node/1879654#comment-7057010
http://drupal.org/node/1358354#comment-7057482

Round two!

http://drupal.org/node/1927636#comment-7116274
http://drupal.org/node/1928682#comment-7120224
http://drupal.org/node/1909634#comment-7138714

Comments

aendra’s picture

Issue summary: View changes

Fixed link.

aendra’s picture

Issue summary: View changes

adding PAReview stuff.

aendra’s picture

Issue summary: View changes

Added another review.

aendra’s picture

Issue tags: +PAreview: review bonus

Adding PAReview bonus tag...

JosefFriedrich’s picture

Hallo Aendrew!

Congratulation to your very nice module!

1. The backup_migrate module is not listet in your README.txt file under Requirements. But it is a dependency for installation.
2. I would be very nice if your module throw out a message via drupa_set_message, if the file git.php is not installed or not in the right place.
3. Is there a way to remove this two module_load_include functions?

module_load_include('inc', 'ghpages', 'ghpages.files');
module_load_include('inc', 'ghpages', 'ghpages.form');

The two pages are loaded every time the module is invoced. So it makes no sense to split the ghpages.module. You reduce no load time.

One way i know is to use following line in the hook_menu function:

'file' => 'yourfile.inc',

/**
 * Implements hook_menu().
 */
function ghpages_menu() {
  $items['admin/config/media/ghpages'] = array(
    'title' => 'Save to GitHub',
    'description' => 'Define GitHub repository and connection settings.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ghpages_admin_settings'),
    'access arguments' => array('save to github'),
    'file' => 'ghpages.form.inc',
  );
  return $items;
}

Dear Josef Friedrich

JosefFriedrich’s picture

Hallo aendrew!

Sorry I forgot:

It would be very nice, if you implement the hook_help() function. You can put in there same help text and the links to configuration pages.

aendra’s picture

@JosefFriedrich -- Thank you for the helpful review! I have:

  • Removed "backup_migrate" from dependencies
  • Added hook_requirements to new file ghpages.install
  • Moved admin-side code into its own file (ghpages.admin.inc), moved the remainder of the two .inc files into main .module file. Removed module_load_include() calls.
  • Added hook_help() page.
  • Added Drush support for downloading the library into the right place ("drush gitphp").
PawelR’s picture

Status: Needs review » Needs work

Hi,

I believe you forgot to commit ghpages.admin.inc file, also you should implement hook_uninstall and delete variables your module creates.

aendra’s picture

Status: Needs work » Needs review

@PawelR -- Ah, whoops! I've added that, as well as implemented hook_uninstall. Thanks for the note!

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

Thanks you for your nice reviews!

manual review:

  1. "define('GITPHP_MIN_PLUGIN_VERSION', '0.1.2');": all constants defined by your module must be prefixed with your module's name to avoid name collisions.
  2. Same for "define('GITPHP_DOWNLOAD_URI', 'https://github.com/kbjr/Git.php/archive/master.zip');"
  3. ghpages_permission(): the second permission is never used?
  4. ghpages_push_files(): $github_server is never used.
  5. "$dir = check_plain($form_state['values']['github_directory']);": why do you use check_plain() here? $dir is never printed to the user? Make sure to read http://drupal.org/node/28984 again.
  6. ghpages_publish_form_submit(): same here, why check_plain()?
  7. ghpages_publish_form_submit(): hook_submit() does not exist, this is a form callback. See http://drupal.org/node/1354#forms
  8. ghpages_publish_form(): same here, document it like http://drupal.org/node/1354#forms
  9. ghpages_admin_settings(): same here.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

aendra’s picture

Status: Needs work » Needs review

Made changes:

1. Defines now have GHPAGES_ prefixed.
2. hook_menu updated to use the second permission ("administer save to github")
3. Unused $github_server var removed.
4. Superfluous check_plain calls removed.
5. ghpages_publish_form() and ghpages_publish_form_submit() documentation improved.

aendra’s picture

Issue summary: View changes

Added another review.

aendra’s picture

Issue summary: View changes

added more bonus links.

aendra’s picture

Issue summary: View changes

added another bonus review.

aendra’s picture

Issue tags: +PAreview: review bonus

Done another three reviews, re-adding tag.

tenken’s picture

Oh cool module! Here's my review.

Automated Review
No errors.

Manual Review

  • Small nitpick -- why is the module name different from the module folder, you have no submodules in the module. I recommend having the module folder name being the same as the module name.
  • In this piece of code, consider actually using $repo_name since you define it:
      $repo_name = basename(variable_get('ghpages_repo', ''), '.git');
      $repo_path = drupal_realpath(
        file_default_scheme() . '://') . '/gh-pages/' .
          basename(variable_get('ghpages_repo', ''),
        '.git');
    
    
  • Consider placing all none HOOK functions found in .module file into a separate ghpages.functions.inc file and leave only hook_ functions in the module file. This is a best practice recommendation.
  • After installing the modules and all dependencies, going to all node/add/page yielded the following notices:
    Notice: Trying to get property of non-object in ghpages_publish_form() (line 390 of /var/www/2013/bits/project_reviews/github_pages/drupal-7.20/sites/all/modules/github_pages/ghpages.module).
    Notice: Trying to get property of non-object in ghpages_publish_form() (line 392 of /var/www/2013/bits/project_reviews/github_pages/drupal-7.20/sites/all/modules/github_pages/ghpages.module).
    Notice: Trying to get property of non-object in ghpages_form_alter() (line 72 of /var/www/2013/bits/project_reviews/github_pages/drupal-7.20/sites/all/modules/github_pages/ghpages.module).
    
  • After saving a simple test drupal page. I get the following error:
    Failed while pushing repo with error message: error: Couldn't resolve host '*********@github.com' while accessing httpx://tenken:@'*********@github.com/tenken/drupal-reviews-sandbox/info/refs fatal: HTTP request failed
    

    Most importanly this error message included my actual github password I supplied in the admin area on the screen as placetext. please dont do that in a status message
    The "Couldnt resolve host" appeared to be using my password, instead of my github username.

tenken’s picture

Status: Needs review » Needs work

oops forgot to change status in #10.

aendra’s picture

Status: Needs work » Needs review

@tenken -- Thanks for the feedback!

a. By your nitpick, you mean "the name of the module as it appears in the .info file"? I've changed that to ghpages.
b. Updated that bit of code to use $repo_name
c. re: ghpages.functions.inc -- I've never heard that, mind pointing me towards some documentation? Regardless, put most helper functions into their own file.
d. Notices are fixed now.
e. I do a check now and replace the password with asterisks if returned via an error.

Are you using the https:// version of the Git URL, and does the repo in question have a gh-pages branch? Should work if so! I've also added some validation to the admin form asking for the https:// version.

klausi’s picture

Status: Needs review » Needs work

Review of the 7.x-1.x branch:

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    FILE: /home/klausi/pareview_temp/ghpages.admin.inc
    --------------------------------------------------------------------------------
    FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
    --------------------------------------------------------------------------------
     48 | ERROR | Function doc comment must end on the line before the function
        |       | definition
     53 | ERROR | Line indented incorrectly; expected 4 spaces, found 6
    --------------------------------------------------------------------------------
    

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. "module_load_include('inc', 'ghpages', 'ghpages.functions');": no need to use module_load_include as you are including files from your own module which you already know where they are. Use something like require_once 'mymodule.inc';
  2. ghpages.module: do not include files in the global module scope, include them in functions when you actually need them.
  3. ghpages.functions.inc is missing?
aendra’s picture

@Klausi -- Gah, forgot to add it. I've now pushed that file to the repo. I've also fixed the automated review notices. Mind looking at it again?

aendra’s picture

Status: Needs work » Needs review
klausi’s picture

Assigned: Unassigned » Michelle
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  1. ghpages_data_process(): getting the node from the menu is really ugly. Better pass it in explicitly and I think you can easily access it from th form_state in the submit handler.
  2. ghpages_data_process(): why do you need to juggle around with global $user? The HTTP request will spawn a new PHP process and you are not sending any session information along, so it will be accessed anonymously. I think you can just remove that part.

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to Michelle as she might have time to take a final look at this.

jthorson’s picture

Assigned: Michelle » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, aendrew!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

aendra’s picture

Terrific! Thanks, jthorson! Huge thanks also to everyone who reviewed my project (JosefFriedrich, PawelR, klausi and tenken)!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

added another review