GithubHelp home page GithubHelp logo

geomit's Introduction

cover

Geomit

A chrome app that attaches your location every git commit to a contributors.geojson file.

Through Git Hooks, HTML5 Geolocation and the Networks Communcation API, Geomit can create Geojson files to be displayed in your Github repositories.

Your location and of any of your contributors who uses Geomit will be attached in a contributors.geojson file in the base of your repository, allowing you to import the rendered map to any webpage through Github's map system.

E.g. Adding this line to a webpage shows the rendered map for this .geojson

  <script src="https://embed.github.com/view/geojson/benbalter/dc-wifi-social/master/bars.geojson"></script>

Why?

After Github's release on mapping geoJSON files, anyone can create a .geojson file and upload it to their Repositories in order to display a nice map about specific information.

Since many open source projects had been crafted with the love of many developers around the globe, I find the possibility of showing a map at the end of every repository under "Contributors" as a token of gratitude to all developers around the globe.

Through Geomit, this file named as contributors.geojson can be easily attached to every repository and then imported to the project Github Pages, showcasing how many developers had been involved in a project and from which part of the globe.

How?

Geomit opens a TCP port through Google Chrome and the Networks Communication API. This port is listening to your localhost all the time. A git pre-hook requests Geomit for your location, retrieved through the Geolocation API from Chrome (if one can be obtained). The location is then retrieve and parsed together with a prevevious contributors.geojson in the repository, or if none, a new one is created. The process ends with the pre-commit adding the contributors.geojson file to your repository.

Instructions

  1. Install Geomit.

  2. Add the pre-commit hook to any repository you want to add a contributors.geojson file (must be a Github repository). Just open your .git/hooks forlder, replace pre-commit.sample for pre-commit and update the pre-commit file with the following content.

#!/usr/bin/env ruby
require 'socket'

=begin
Current workflow...
Geomit opens (TCP Server loads)
Pre-commit hook triggers
Pre-commit opens CWD/contributors.geojson
  if something
    Pre-commit hook sends CWD/contributors.geojson and hangs
    Geomit answers with the updated contributors.geojson
    Pre-commit hook writes the updated contributors.geojson
  else
    Geomit answers with the new contributors.geojson
    Pre-commit hook writes the new contributors.geojson
=end

# Configurable
host = 'localhost'
port = 8888

# Constants
FNAME = '/contributors.geojson'
SIZE = 1024 * 1024 * 10
CONTRIBUTORS = Dir.pwd + FNAME

# Init...
puts "Connecting to Geomit..."
s = TCPSocket.new host, port
sleep 1 

getRepoNameCommand = "basename `git rev-parse --show-toplevel`"
getUsernameCommand = "git ls-remote --get-url"
getPrevSHACommand = "git rev-parse --verify HEAD"

# Communication Test
repourl = `#{getUsernameCommand}`
username = /[email protected]:(\w*)\/.*/.match(repourl)[1]

reponame = `#{getRepoNameCommand}`
sha = `#{getPrevSHACommand}`

s.send "Greetings from "+username+", repo "+reponame, 0

# Retrieving 
puts "Retrieving contributors.geojson"
if File.file?(CONTRIBUTORS)
  puts "Found. Sending to Geomit"
  s.send '{"receive": "true", "username": "'+username+'", "sha": "'+sha.chomp+'"}', 0
  sleep 1
  File.open(Dir.pwd + FNAME, 'rb') do |file|
    while chunk = file.read(SIZE)
      s.write(chunk)
    end
  end
else
  puts "Not found. Creating contributos.geojson"
  s.send '{"create": "true", "username": "'+username+'", "sha": "'+sha.chomp+'"}', 0
end

geojson = s.recv(SIZE)

puts "Updating contributors.geojson"
unless geojson.nil?
  File.open(CONTRIBUTORS, 'w') do |file| 
    file.write(geojson)
  end
end

puts "Completed updating contributors.geojson"
gitAddContributors = "git add contributors.geojson"

`#{gitAddContributors}`
  1. Launch Geomit, which will prompt then a welcome message and a listening port display.

  2. Continue working as you would normally, ignoring Geomit. Every time you perform a commit, Geomit will retrieve your location, see if there's a contributors.geojson file already and add yours, or create a new one if there's none.

Security

Anyone (or anything) listening to Geomit's TCP port can retrieve the communication between Geomit and the Pre-commit hook, thus, obtaining your location. Although a security protocol was considered in order to hinder this problem, your shouldn't be sharing your location in a Github repository to begin with if security it's a main concern for you.

Limitations

Currently Geomit relies heavily in your OSX and Ruby to get your github username, your contributors.geojson file (if any) and other data. For the moment, it only works with a github domain (it's not too hard to update the regex that parses this, but wasn't a priority, as the maps are only parsed by Github)

Geomit requires the usage of Ruby for connecting to TCP as part of a Pre-commit hook. Future releases might include other languages version.

Since it's a Chrome Extension, it also requires Google Chrome. However, being a packaged app, its limitations are not as bad as the ones from a Chrome Extension such as needing Google Chrome open. As long as Geomit is open, it can perform all the required actions to retrieve your location.

Roadamp

  • Adding multiple languages support (python, nodejs, shell)
  • Adding more information to the Geojson maps.

geomit's People

Contributors

0xjjpa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.