Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Holek committed May 11, 2014
0 parents commit 7a6877f
Show file tree
Hide file tree
Showing 96 changed files with 9,653 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.bundle
.ruby-version
.ruby-gemset
.rvmrc
db/*.sqlite3
log/*.log
tmp/
.sass-cache/
vendor/gems
nbproject
config/database.yml
config/settings.yml
config/salesking_app.yml
coverage
.idea
public/assets
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour
2 changes: 2 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy/production'
35 changes: 35 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
source 'http://rubygems.org'

gem 'rails', '> 4'
gem 'json'
gem 'sk_sdk', :git=>'https://github.com/salesking/sk_sdk.git', branch: 'master'
gem 'sk_api_schema', '~> 0.9.4'
gem 'haml'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'rack-raw-upload'
gem 'cancan'

gem 'unicorn'
gem 'pg'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'therubyracer'

group :test, :development do
gem 'rspec-rails', '~> 2.6'
gem 'factory_girl_rails'
gem 'shoulda-matchers'
gem 'simplecov'
gem 'mysql2'
gem 'pry-rails'
end

group :development do
gem 'better_errors'
gem 'thin'
gem 'capistrano', '<3'
gem 'capistrano-ext'
gem 'quiet_assets'
end
225 changes: 225 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
GIT
remote: https://github.com/salesking/sk_sdk.git
revision: 9e6778e4d81f48a460c9c0cf6e10324b96e81906
branch: master
specs:
sk_sdk (0.3.0)
activeresource
activesupport
curb
sk_api_schema

GEM
remote: http://rubygems.org/
specs:
actionmailer (4.0.5)
actionpack (= 4.0.5)
mail (~> 2.5.4)
actionpack (4.0.5)
activesupport (= 4.0.5)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.5)
activesupport (= 4.0.5)
builder (~> 3.1.0)
activerecord (4.0.5)
activemodel (= 4.0.5)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.5)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activeresource (4.0.0)
activemodel (~> 4.0)
activesupport (~> 4.0)
rails-observers (~> 0.1.1)
activesupport (4.0.5)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.2)
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
builder (3.1.4)
cancan (1.6.10)
capistrano (2.15.5)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
capistrano-ext (1.2.1)
capistrano (>= 1.0.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.7.0)
curb (0.8.5)
daemons (1.1.9)
diff-lcs (1.2.5)
docile (1.1.3)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.2)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.4.1)
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
haml (4.0.5)
tilt
highline (1.6.21)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (1.8.1)
kgio (2.9.2)
libv8 (3.16.14.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25.1)
minitest (4.7.5)
multi_json (1.10.0)
mysql2 (0.3.15)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.9.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
pg (0.17.1)
polyglot (0.3.4)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry-rails (0.3.2)
pry (>= 0.9.10)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.5.2)
rack-raw-upload (1.1.1)
multi_json
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.5)
actionmailer (= 4.0.5)
actionpack (= 4.0.5)
activerecord (= 4.0.5)
activesupport (= 4.0.5)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.5)
sprockets-rails (~> 2.0.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
railties (4.0.5)
actionpack (= 4.0.5)
activesupport (= 4.0.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.3.1)
ref (1.0.5)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.3.7)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
sk_api_schema (0.9.5)
activesupport
slop (3.4.7)
sprockets (2.12.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thin (1.6.2)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.39)
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)

PLATFORMS
ruby

DEPENDENCIES
better_errors
cancan
capistrano (< 3)
capistrano-ext
coffee-rails
factory_girl_rails
haml
jquery-rails
jquery-ui-rails
json
mysql2
pg
pry-rails
quiet_assets
rack-raw-upload
rails (> 4)
rspec-rails (~> 2.6)
sass-rails
shoulda-matchers
simplecov
sk_api_schema (~> 0.9.4)
sk_sdk!
therubyracer
thin
uglifier
unicorn
57 changes: 57 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SalesKing Line Item Importer

A SalesKing app to import csv files. As a starting point you can import
contacts given as csv f.ex exported from Outlook.

## Developer Info

The app is build with Rails 3.1 and Ruby 1.9.2 and is working with
MySQL or PostgreSQL.
It uses oAuth2 and has a canvas integration, so a user can use
it inside SalesKing.

## Getting Started

1. Register a new app to get an app-id & secret in your SalesKing account.

* Set a unique CANVAS SLUG so it can be reached inside salesking.eu/app/my-import
* Set the Canvas URL to `http://MY-URL.local/login` <- /login receives the auth POST when a user opens the app in sk/app/my-import

2. Checkout this repo, copy and edit `salesking_app.yml` & `database.yml`.

bundle install
bundle exec rake db:migrate
bundle exec rails s

3. Go into SalesKing at `/app/your-canvas-slug`

## Run on Heroku

This app is deployed on Heroku and [you can do it too](http://devcenter.heroku.com/articles/rails31_heroku_cedar). The only problem to be
solved is the creation of the salesking_app.yml keeping the app
key & secret.
Instead of using [Heroku's env_vars](http://devcenter.heroku.com/articles/config-vars) you should use a separate
local git branch where you add the ignored `salesking_app.yml` file:

# create a new branch
git checkout production
# [create salesking_app.yml, remove from .gitignore and commit]
git merge master
git push heroku production:master
# change back to master branch for normal edits .. DO NOT merge production into master
git checkout master

DON'T FORGET: never push production to your public branch, if you do you need to setup NEW app credentials


## Test

Run specs with

bundle exec rake spec

Test coverage report is created by simpleCov and available after running the
specs


Copyright (c) 2011 Georg Leciejewski, released under the MIT license
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

LineItemImporter::Application.load_tasks
Binary file added app/assets/images/destroy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//= require jquery

//= require jquery.ui.all
//= require fileuploader
//= require_tree .
42 changes: 42 additions & 0 deletions app/assets/javascripts/attachments.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
jQuery ->
$('#csv-refresh').click ->
$.ajax
url: $('#new_attachment').attr('action'),
type: 'POST',
dataType: 'json',
data:
'_method': 'put',
'attachment[col_sep]': $('#attachment_col_sep').val(),
'attachment[quote_char]': $("#attachment_quote_char").val(),
'attachment[encoding]': $("#attachment_encoding").val()
,
success: (data) -> insertFields(data)
false

if $('#file-upload').length > 0
uploader = new qq.FileUploader
multiple: false,
element: document.getElementById("file-upload"),
action: '/attachments',
allowedExtensions: ["txt", "csv"],
sizeLimit: 5048576,
onSubmit: (id, fileName) ->
uploader.setParams
authenticity_token: $("input[name='authenticity_token']").val()
col_sep: $("#attachment_col_sep").val()
quote_char: $("#attachment_quote_char").val()
encoding: $("#attachment_encoding").val()
,
onComplete: (id, fileName, data) ->
insertFields(data)
$('#new_attachment').attr('action', '/attachments/' + data.id)

insertFields = (data) ->
csv = ['<table class="table table-bordered">']
$.each data.rows, (index, row) ->
csv.push '<tr>'
$.each row, (index, value) -> csv.push('<td>' + (if value then value else '') + '</td>')
csv.push '</tr>'
csv.push '</table>'
$('#csv-table table').remove()
$('#csv-table').show().append csv.join('')
Loading

0 comments on commit 7a6877f

Please sign in to comment.