Skip to content

Commit

Permalink
Style check coffeescript files.
Browse files Browse the repository at this point in the history
  • Loading branch information
NatTuck committed Mar 5, 2014
1 parent 36a45e0 commit a72525b
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 114 deletions.
114 changes: 114 additions & 0 deletions .coffeelint
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"coffeescript_error": {
"level": "error"
},
"arrow_spacing": {
"name": "arrow_spacing",
"level": "error"
},
"no_tabs": {
"name": "no_tabs",
"level": "error"
},
"no_trailing_whitespace": {
"name": "no_trailing_whitespace",
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": true
},
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": true
},
"line_endings": {
"name": "line_endings",
"level": "error",
"value": "unix"
},
"no_trailing_semicolons": {
"name": "no_trailing_semicolons",
"level": "error"
},
"indentation": {
"name": "indentation",
"value": 2,
"level": "error"
},
"camel_case_classes": {
"name": "camel_case_classes",
"level": "error"
},
"colon_assignment_spacing": {
"name": "colon_assignment_spacing",
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"no_implicit_braces": {
"name": "no_implicit_braces",
"level": "ignore",
"strict": true
},
"no_plusplus": {
"name": "no_plusplus",
"level": "ignore"
},
"no_throwing_strings": {
"name": "no_throwing_strings",
"level": "error"
},
"no_backticks": {
"name": "no_backticks",
"level": "error"
},
"no_implicit_parens": {
"name": "no_implicit_parens",
"level": "ignore"
},
"no_empty_param_list": {
"name": "no_empty_param_list",
"level": "ignore"
},
"no_stand_alone_at": {
"name": "no_stand_alone_at",
"level": "ignore"
},
"space_operators": {
"name": "space_operators",
"level": "error"
},
"duplicate_key": {
"name": "duplicate_key",
"level": "error"
},
"empty_constructor_needs_parens": {
"name": "empty_constructor_needs_parens",
"level": "ignore"
},
"cyclomatic_complexity": {
"name": "cyclomatic_complexity",
"value": 10,
"level": "ignore"
},
"newlines_after_classes": {
"name": "newlines_after_classes",
"value": 3,
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"name": "no_unnecessary_fat_arrows",
"level": "warn"
},
"missing_fat_arrows": {
"name": "missing_fat_arrows",
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"name": "non_empty_constructor_needs_parens",
"level": "ignore"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ log/*
db/data.yml*

coverage/*

db/test.sqlite3-journal
node_modules/

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ group :development, :test do
gem "simplecov"
gem "turn"
gem "rubocop", git: 'https://github.com/bbatsov/rubocop'
gem "coffeelint"
end

# Jquery stuff
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ GEM
coffeebeans (1.0.1)
actionpack (>= 3.0.0)
coffee-script
coffeelint (0.2.0)
coffee-script
json
docile (1.1.3)
erubis (2.7.0)
execjs (2.0.2)
Expand Down Expand Up @@ -209,6 +212,7 @@ DEPENDENCIES
coffee-rails
coffee-rails-source-maps
coffeebeans
coffeelint
execjs
font-awesome-rails
httparty
Expand Down
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ if %w(development test).include? Rails.env
task.formatters = ['fuubar']
end

task(:default).clear
task(:coffeelint).clear
task :coffeelint do
conf = Rails.root.join('.coffeelint')
success = Coffeelint.run_test_suite('app', config_file: conf.to_s) and
Coffeelint.run_test_suite('spec', config_file: conf.to_s)
fail "Goats!" unless success
end

task(:default).clear
task :default do
Rake::Task["coffeelint"].invoke
Rake::Task["rubocop"].invoke
Rake::Task["test"].invoke
end
Expand Down
28 changes: 16 additions & 12 deletions app/assets/javascripts/ckTemplates.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ present in 'all' will always be used as a default.

$ ->
if namespace.controller is "projects"
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "Project Template"
Expand Down Expand Up @@ -35,7 +35,9 @@ $ ->
<p>SOURCE</p>
<p>
If the project contains an existing data set, please specify the source of
the data, including a web link or bibliographical reference. (E.g., <a href="http://www.crwa.org/water_quality.html">http://www.crwa.org/water_quality.html</a>)
the data, including a web link or bibliographical reference.
(E.g., <a href="http://www.crwa.org/water_quality.html">
http://www.crwa.org/water_quality.html</a>)
</p>
"""
# },{
Expand All @@ -46,12 +48,12 @@ $ ->

if namespace.controller is "visualizations" and namespace.action is "displayVis"
#add dataset templates here
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "Dataset Template"
description: "Basic template for describing a dataset."
html: """
html: """
<p>COLLECTION METHOD</p>
<p>
Please describe how, when, and where these data were collected. (E.g. This
Expand All @@ -60,17 +62,19 @@ $ ->
Science in the Charles River's lower basin.)
</p>
<p>DATA SOURCE</p>
<p>DATA SOURC`E</p>
<p>
For existing data sets, please specify where the data were obtained. (E.g.
These data were provided online by the Charles River Watershed Association. <a href="http://www.crwa.org/water_quality.html">http://www.crwa.org/water_quality.html</a>)
These data were provided online by the Charles River Watershed Association.
<a href="http://www.crwa.org/water_quality.html">
http://www.crwa.org/water_quality.html</a>)
</p>
"""
}]

if namespace.controller is "visualizations" and namespace.action is "show"
#add saved vis templates here
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "Visualization Template"
Expand Down Expand Up @@ -103,12 +107,12 @@ $ ->

if namespace.controller is "users"
#add bio templates here
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "User Template"
description: "Basic template for user biography."
html: """
html: """
<p>INSTITUTIONAL AFFILIATION</p>
<p>
Please describe your institutional affiliation(s). (E.g., I teach
Expand All @@ -127,7 +131,7 @@ $ ->

if namespace.controller is "tutorials"
#add tutorial templates here
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "Blank Template"
Expand All @@ -138,11 +142,11 @@ $ ->

if namespace.controller is "news"
#add news templates here
CKEDITOR.addTemplates "all",
CKEDITOR.addTemplates "all",
templates:
[{
title: "Blank Template"
description: "This is a blank template."
html: """ """
}]


47 changes: 27 additions & 20 deletions app/assets/javascripts/data_sets/manualEntry.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ $ ->
method: 'POST'
error: (j, s, t) =>

($ '.mainContent').prepend "<div class='alert alert-danger alert-dismissable'><strong>An error occured: </strong> Data set names must be unique to their project.</div>"
($ '.mainContent').prepend(
"<div class='alert alert-danger alert-dismissable'><strong>An error occured: </strong>" +
"Data set names must be unique to their project.</div>"
)

($ '#manualTable th').each (header_i, header) ->
($ header).wrapInner "<div class='center'></div>"
Expand All @@ -25,7 +28,10 @@ $ ->

($ '#manualTable tr').slice(1).each (row_i, row) ->
($ row).find('td').each (col_i, col) ->
($ col).replaceWith "<td><div class='center'><input type='text' class='form-control' value='#{ ($ col).text() }'></div></td>"
($ col).replaceWith(
"<td><div class='center'><input type='text' class='form-control'" +
"value='#{ ($ col).text() }'></div></td>"
)

($ row).append "<td><div class='center'><a class='close' style='float:none;'>&times;</a></div></td>"
($ row).find('.close').click ->
Expand All @@ -49,7 +55,8 @@ $ ->
do (col) ->
($ row).children().eq(col).find('input').replaceWith """
<div class='input-group'>
<input class='validate_longitude form-control ' id='appendedInput' type='text' value='#{ ($ row).find('input').eq(col).val() }' />
<input class='validate_longitude form-control ' id='appendedInput'
type='text' value='#{ ($ row).find('input').eq(col).val() }' />
<span class='input-group-btn'>
<a href='#' tabindex='32767' class="btn btn-default map_picker">
<i class='fa fa-globe'></i>
Expand All @@ -75,7 +82,8 @@ $ ->
do (col) ->
($ row).children().eq(col).find('input').replaceWith """
<div class='input-group datepicker'>
<input class='validate_timestamp form-control' type='text' data-format='yyyy/MM/dd hh:mm:ss' value='#{ ($ row).find('input').eq(col).val() }' />
<input class='validate_timestamp form-control' type='text'
data-format='yyyy/MM/dd hh:mm:ss' value='#{ ($ row).find('input').eq(col).val() }' />
<span class='input-group-btn'>
<a href='#' tabindex='32767' class="btn btn-default">
<i class='fa fa-calendar'></i>
Expand All @@ -99,23 +107,22 @@ $ ->
time_cols = []

update_headers = () ->
# separate columns by field type/validator
# separate columns by field type/validator

num_cols = []
lat_cols = []
lon_cols = []
text_cols = []
time_cols = []
num_cols = []
lat_cols = []
lon_cols = []
text_cols = []
time_cols = []

($ '#manualTable').find('th').each (index) ->
type = ($ @).attr 'data-field-type'
($ '#manualTable').find('th').each (index) ->
type = ($ @).attr 'data-field-type'

switch type
when "Timestamp" then time_cols.push index
when "Text" then text_cols.push index
when "Number" then num_cols.push index
when "Latitude" then lat_cols.push index
when "Latitude" then add_map()
when "Longitude" then lon_cols.push index
switch type
when "Timestamp" then time_cols.push index
when "Text" then text_cols.push index
when "Number" then num_cols.push index
when "Latitude" then lat_cols.push index
when "Latitude" then add_map()
when "Longitude" then lon_cols.push index


10 changes: 7 additions & 3 deletions app/assets/javascripts/data_sets/show.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ $ ->
mongo_data = window.mongo_data

sort[field.id] = [] for field in fields

metadata.push {name: field['name'], label: field['name'], dataType:'string', id: field['id'], editable:'true'} for field in fields

for field in fields
metadata.push {
name: field['name'], label: field['name'], dataType:'string',
id: field['id'], editable:'true'
}

for row in mongo_data
do (row) ->
Expand All @@ -20,4 +24,4 @@ $ ->
sort[key].push data_point[key]

keys = Object.keys sort
data.push {id: key, values: sort[key] } for key in keys
data.push {id: key, values: sort[key] } for key in keys
Loading

0 comments on commit a72525b

Please sign in to comment.