Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
226 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class BoardController < ApplicationController | ||
def index | ||
UseCase::FetchBoard.new(huboard).run(params).match do | ||
success do | ||
@repo = gh.repos(params[:user],params[:repo]) | ||
render :index, layout: "ember" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<% content_for :title do %> | ||
<%= @repo['full_name'] %> | ||
<% end %> | ||
<% content_for :javascripts do %> | ||
<% unless ENV["SOCKET_BACKEND"].nil? %> | ||
<script src='<%= ENV['SOCKET_BACKEND']%>/client.js'></script> | ||
<% end %> | ||
<%= javascript_include_tag 'board/application' %> | ||
<%= javascript_include_tag 'bootstrap' %> | ||
<%= javascript_include_tag 'vendor/jquery-ui' %> | ||
<script> | ||
(function($) { | ||
var _mouseDrag = $.ui.sortable.prototype._mouseDrag; | ||
$.ui.sortable.prototype._mouseDrag = function(event) { | ||
var i, item, itemElement, intersection, | ||
o = this.options, | ||
scrolled = false; | ||
|
||
//Do scrolling | ||
|
||
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { | ||
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); | ||
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { | ||
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); | ||
} | ||
|
||
|
||
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { | ||
$.ui.ddmanager.prepareOffsets(this, event); | ||
} | ||
return _mouseDrag.apply(this, arguments); | ||
}; | ||
|
||
})(jQuery); | ||
App.set("repo", Ember.Object.createWithMixins(App.Serializable,<%= @repo.to_hash.to_json.html_safe %>)); | ||
<% if logged_in? %> | ||
App.set("loggedIn", true); | ||
App.set("authLevel", "<%= @auth_level %>") | ||
App.set("currentUser",<%= current_user.attribs.to_json.html_safe %>); | ||
<% if Rails.application.config.sockets.socket_backend %> | ||
App.set("socketBackend", "<%= Rails.application.config.sockets.socket_backend %>"); | ||
<% end %> | ||
<% else %> | ||
App.set("loggedIn", false); | ||
<% end %> | ||
|
||
if(window.analytics) { | ||
App.Router.reopen({ | ||
notifySegmentIo: function(){ | ||
return window.analytics.page(this.get('url'),{ | ||
page: this.get('url'), | ||
title: this.get('url') | ||
}) | ||
}.on("didTransition") | ||
|
||
}); | ||
|
||
} | ||
|
||
App.advanceReadiness(); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title><%= content_for :title %>HuBoard</title> | ||
<meta name="description" content="Instant project management for GitHub issues"> | ||
<link rel="shortcut icon" href="/favicon.ico?v=3" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<%= stylesheet_link_tag 'bootstrap' %> | ||
<%= stylesheet_link_tag 'flex_layout' %> | ||
|
||
|
||
</head> | ||
<body class="flex-body"> | ||
<div id="application"> | ||
</div> | ||
<%= content_for :overlay %> | ||
<%= render partial: "shared/analytics" %> | ||
<script> | ||
window.EMOJIS = <%= emojis.to_json.html_safe %>; | ||
window.HUBOARD_ENV = <%= Rails.application.config.client_environment.to_json.html_safe %>; | ||
</script> | ||
<%= content_for :javascripts %> | ||
<%= render partial: "shared/fontdeck" %> | ||
|
||
|
||
</body> | ||
</html> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Rails.application.config.client_environment = JSON.parse(File.read("#{Rails.root}/features.json")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Rails.application.config.sockets = OpenStruct.new( | ||
socket_backend: ENV["SOCKET_BACKEND"], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"FEATURES" : { | ||
"IMAGE_UPLOADS": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module UseCase | ||
class FetchBoard | ||
include SolidUseCase | ||
|
||
attr_accessor :client | ||
|
||
def initialize(client) | ||
@client = client | ||
end | ||
|
||
steps :repo_exists?, :board_exists?, :issues_enabled? | ||
|
||
def repo_exists? params | ||
board = client.board params[:user], params[:repo] | ||
if board.repo_exists? | ||
continue board | ||
else | ||
fail :not_found | ||
end | ||
|
||
end | ||
|
||
def board_exists?(board) | ||
if board.has_board? | ||
continue board | ||
else | ||
fail :no_board | ||
end | ||
end | ||
|
||
def issues_enabled?(board) | ||
if board.issues_enabled? | ||
continue board | ||
else | ||
fail :no_issues | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require "app/account_helpers" | ||
|
||
module UseCase | ||
class PrivateRepo | ||
include HuBoard::AccountHelpers | ||
include SolidUseCase | ||
|
||
attr_accessor :couch, :gh | ||
def initialize(gh, couch) | ||
@gh = gh | ||
@couch = couch | ||
end | ||
|
||
steps :an_account_exists?, :a_trial_available?, :has_subscription? | ||
|
||
def an_account_exists?(params) | ||
@repo_owner ||= @gh.users(params[:user]) | ||
|
||
plan_doc = QueryHandler.run do |q| | ||
q << Queries::CouchCustomer.get(@repo_owner["id"], @couch) | ||
q << Queries::PassThrough.go | ||
end | ||
return fail(:pass_through) if plan_doc[:pass_through] | ||
|
||
@customer = account_exists?(plan_doc) ? plan_doc[:rows].first.value : false | ||
continue(params) | ||
end | ||
|
||
def a_trial_available?(params) | ||
if trial_available?(@customer) && user_is_owner(params) | ||
params[:trial_available] = true | ||
continue(params) | ||
else | ||
continue(params) | ||
end | ||
end | ||
|
||
def has_subscription?(params) | ||
return continue(params) if params[:trial_available] || trial_active?(@customer) | ||
if @customer && subscription_active?(@customer) | ||
return continue(params) | ||
end | ||
return fail :unauthorized | ||
end | ||
|
||
:private | ||
def user_is_owner(params) | ||
if @repo_owner["type"] == "Organization" | ||
@u ||= @gh.orgs(@repo_owner["login"]).memberships(@gh.user["login"]) do |req| | ||
req.headers["Accept"] = "application/vnd.github.moondragon+json" | ||
end | ||
return @u["role"] == "admin" | ||
end | ||
@repo_owner['login'] == @gh.user['login'] | ||
end | ||
end | ||
end |