Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit febad48ae164e9459cf4e3c8f5093f7b173e7bb8 @ankane committed Oct 1, 2014
Showing with 27,519 additions and 0 deletions.
  1. +14 −0 .gitignore
  2. +4 −0 Gemfile
  3. +22 −0 LICENSE.txt
  4. +144 −0 README.md
  5. +2 −0 Rakefile
  6. +11 −0 app/assets/javascripts/blazer/ace/ace.js
  7. +5 −0 app/assets/javascripts/blazer/ace/ext-language_tools.js
  8. +1 −0 app/assets/javascripts/blazer/ace/mode-sql.js
  9. +1 −0 app/assets/javascripts/blazer/ace/snippets/sql.js
  10. +1 −0 app/assets/javascripts/blazer/ace/snippets/text.js
  11. +1 −0 app/assets/javascripts/blazer/ace/theme-twilight.js
  12. +15 −0 app/assets/javascripts/blazer/application.js
  13. +1,026 −0 app/assets/javascripts/blazer/daterangepicker.js
  14. +1 −0 app/assets/javascripts/blazer/highlight.pack.js
  15. +10,308 −0 app/assets/javascripts/blazer/jquery.js
  16. +263 −0 app/assets/javascripts/blazer/jquery.stickytableheaders.js
  17. +469 −0 app/assets/javascripts/blazer/jquery_ujs.js
  18. +1,474 −0 app/assets/javascripts/blazer/list.js
  19. +2,400 −0 app/assets/javascripts/blazer/moment.js
  20. +3,477 −0 app/assets/javascripts/blazer/selectize.js
  21. +114 −0 app/assets/javascripts/blazer/stupidtable.js
  22. +66 −0 app/assets/stylesheets/blazer/application.css
  23. +6,203 −0 app/assets/stylesheets/blazer/bootstrap.css
  24. +1 −0 app/assets/stylesheets/blazer/bootstrap.css.map
  25. +267 −0 app/assets/stylesheets/blazer/daterangepicker-bs3.css
  26. +126 −0 app/assets/stylesheets/blazer/github.css
  27. +386 −0 app/assets/stylesheets/blazer/selectize.default.css
  28. +216 −0 app/controllers/blazer/queries_controller.rb
  29. +21 −0 app/helpers/blazer/queries_helper.rb
  30. +5 −0 app/models/blazer/audit.rb
  31. +5 −0 app/models/blazer/connection.rb
  32. +13 −0 app/models/blazer/query.rb
  33. +84 −0 app/views/blazer/queries/_form.html.erb
  34. +1 −0 app/views/blazer/queries/edit.html.erb
  35. +47 −0 app/views/blazer/queries/index.html.erb
  36. +1 −0 app/views/blazer/queries/new.html.erb
  37. +50 −0 app/views/blazer/queries/run.html.erb
  38. +138 −0 app/views/blazer/queries/show.html.erb
  39. +17 −0 app/views/layouts/blazer/application.html.erb
  40. +25 −0 blazer.gemspec
  41. +6 −0 config/routes.rb
  42. +16 −0 lib/blazer.rb
  43. +11 −0 lib/blazer/engine.rb
  44. +3 −0 lib/blazer/version.rb
  45. +33 −0 lib/generators/blazer/install_generator.rb
  46. +8 −0 lib/generators/blazer/templates/config.yml
  47. +17 −0 lib/generators/blazer/templates/install.rb
@@ -0,0 +1,14 @@
+/.bundle/
+/.yardoc
+/Gemfile.lock
+/_yardoc/
+/coverage/
+/doc/
+/pkg/
+/spec/reports/
+/tmp/
+*.bundle
+*.so
+*.o
+*.a
+mkmf.log
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in blazer.gemspec
+gemspec
@@ -0,0 +1,22 @@
+Copyright (c) 2014 Andrew Kane
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,144 @@
+# Blazer
+
+Create and share SQL queries instantly
+
+[View the demo](https://blazerme.herokuapp.com)
+
+Works with PostgreSQL and MySQL
+
+:tangerine: Battle-tested at [Instacart](https://www.instacart.com)
+
+## Features
+
+- **Secure** - works with your authentication system
+- **Variables** - get the same insights for multiple values
+- **Linked Columns** - link to other pages in your apps or around the web
+- **Smart Columns** - get the data your want without all the joins
+- **Smart Variables** - no need to remember IDs
+- **Charts & Maps** - a picture is worth a thousand words
+
+Documentation coming soon.
+
+## Installation
+
+Add this line to your application’s Gemfile:
+
+```ruby
+gem 'blazer'
+```
+
+Run:
+
+```sh
+rails g blazer:install
+rake db:migrate
+```
+
+And mount the dashboard in your `config/routes.rb`:
+
+```ruby
+mount Blazer::Engine, at: "blazer"
+```
+
+Then, specify your database:
+
+```ruby
+ENV["BLAZER_DATABASE_URL"]
+```
+
+It is **highly, highly recommended** to use a read only user. Keep reading to see how to create one.
+
+## Permissions
+
+### PostgreSQL
+
+Create a user with read only permissions:
+
+```sql
+BEGIN;
+CREATE ROLE blazer LOGIN PASSWORD 'secret123';
+GRANT CONNECT ON DATABASE database_name TO blazer;
+GRANT USAGE ON SCHEMA public TO blazer;
+COMMIT;
+```
+
+It’s highly recommended to protect sensitive information with views. Documentation coming soon.
+
+### MySQL
+
+Create a user with read only permissions:
+
+```sql
+GRANT SELECT, SHOW VIEW ON database_name.* TO blazer@’127.0.0.1′ IDENTIFIED BY ‘secret123‘;
+FLUSH PRIVILEGES;
+```
+
+It’s highly recommended to protect sensitive information with views. Documentation coming soon.
+
+## Authentication
+
+Don’t forget to protect the dashboard in production.
+
+### Basic Authentication
+
+Set the following variables in your environment or an initializer.
+
+```ruby
+ENV["BLAZER_USERNAME"] = "andrew"
+ENV["BLAZER_PASSWORD"] = "secret"
+```
+
+### Devise
+
+```ruby
+authenticate :user, lambda{|user| user.admin? } do
+ mount Blazer::Engine, at: "blazer"
+end
+```
+
+## Customization
+
+Change time zone
+
+```ruby
+Blazer.time_zone = "Pacific Time (US & Canada)"
+```
+
+Turn off audits
+
+```ruby
+Blazer.audit = false
+```
+
+## TODO
+
+- better readme
+- better navigation
+- standalone version
+- update lock
+- warn when database user has write permissions
+- advanced permissions
+- favorites
+- support for multiple data sources
+
+## Thanks
+
+Blazer uses a number of awesome, open source projects.
+
+- [Rails](https://github.com/rails/rails/)
+- [jQuery](https://github.com/jquery/jquery)
+- [Bootstrap](https://github.com/twbs/bootstrap)
+- [Selectize](https://github.com/brianreavis/selectize.js)
+- [List.js](https://github.com/javve/list.js)
+- [StickyTableHeaders](https://github.com/jmosbech/StickyTableHeaders)
+- [Stupid jQuery Table Sort](https://github.com/joequery/Stupid-Table-Plugin)
+- [Date Range Picker](https://github.com/dangrossman/bootstrap-daterangepicker)
+
+## Contributing
+
+Everyone is encouraged to help improve this project. Here are a few ways you can help:
+
+- [Report bugs](https://github.com/ankane/blazer/issues)
+- Fix bugs and [submit pull requests](https://github.com/ankane/blazer/pulls)
+- Write, clarify, or fix documentation
+- Suggest or add new features
@@ -0,0 +1,2 @@
+require "bundler/gem_tasks"
+
Oops, something went wrong.
Oops, something went wrong.
@@ -0,0 +1 @@
+ace.define("ace/mode/sql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){var e="select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|when|else|end|type|left|right|join|on|outer|desc|asc",t="true|false|null",n="count|min|max|avg|sum|rank|now|coalesce",r=this.createKeywordMapper({"support.function":n,keyword:e,"constant.language":t},"identifier",!0);this.$rules={start:[{token:"comment",regex:"--.*$"},{token:"comment",start:"/\\*",end:"\\*/"},{token:"string",regex:'".*?"'},{token:"string",regex:"'.*?'"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:r,regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="},{token:"paren.lparen",regex:"[\\(]"},{token:"paren.rparen",regex:"[\\)]"},{token:"text",regex:"\\s+"}]},this.normalizeRules()};r.inherits(s,i),t.SqlHighlightRules=s}),ace.define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules","ace/range"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./sql_highlight_rules").SqlHighlightRules,o=e("../range").Range,u=function(){this.HighlightRules=s};r.inherits(u,i),function(){this.lineCommentStart="--",this.$id="ace/mode/sql"}.call(u.prototype),t.Mode=u})
@@ -0,0 +1 @@
+ace.define("ace/snippets/sql",["require","exports","module"],function(e,t,n){"use strict";t.snippetText="snippet tbl\n create table ${1:table} (\n ${2:columns}\n );\nsnippet col\n ${1:name} ${2:type} ${3:default ''} ${4:not null}\nsnippet ccol\n ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}\nsnippet ncol\n ${1:name} number ${3:default 0} ${4:not null}\nsnippet dcol\n ${1:name} date ${3:default sysdate} ${4:not null}\nsnippet ind\n create index ${3:$1_$2} on ${1:table}(${2:column});\nsnippet uind\n create unique index ${1:name} on ${2:table}(${3:column});\nsnippet tblcom\n comment on table ${1:table} is '${2:comment}';\nsnippet colcom\n comment on column ${1:table}.${2:column} is '${3:comment}';\nsnippet addcol\n alter table ${1:table} add (${2:column} ${3:type});\nsnippet seq\n create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\nsnippet s*\n select * from ${1:table}\n",t.scope="sql"})
@@ -0,0 +1 @@
+ace.define("ace/snippets/text",["require","exports","module"],function(e,t,n){"use strict";t.snippetText=undefined,t.scope="text"})
@@ -0,0 +1 @@
+ace.define("ace/theme/twilight",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-twilight",t.cssText=".ace-twilight .ace_gutter {background: #232323;color: #E2E2E2}.ace-twilight .ace_print-margin {width: 1px;background: #232323}.ace-twilight {background-color: #141414;color: #F8F8F8}.ace-twilight .ace_cursor {color: #A7A7A7}.ace-twilight .ace_marker-layer .ace_selection {background: rgba(221, 240, 255, 0.20)}.ace-twilight.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #141414;border-radius: 2px}.ace-twilight .ace_marker-layer .ace_step {background: rgb(102, 82, 0)}.ace-twilight .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgba(255, 255, 255, 0.25)}.ace-twilight .ace_marker-layer .ace_active-line {background: rgba(255, 255, 255, 0.031)}.ace-twilight .ace_gutter-active-line {background-color: rgba(255, 255, 255, 0.031)}.ace-twilight .ace_marker-layer .ace_selected-word {border: 1px solid rgba(221, 240, 255, 0.20)}.ace-twilight .ace_invisible {color: rgba(255, 255, 255, 0.25)}.ace-twilight .ace_keyword,.ace-twilight .ace_meta {color: #CDA869}.ace-twilight .ace_constant,.ace-twilight .ace_constant.ace_character,.ace-twilight .ace_constant.ace_character.ace_escape,.ace-twilight .ace_constant.ace_other,.ace-twilight .ace_heading,.ace-twilight .ace_markup.ace_heading,.ace-twilight .ace_support.ace_constant {color: #CF6A4C}.ace-twilight .ace_invalid.ace_illegal {color: #F8F8F8;background-color: rgba(86, 45, 86, 0.75)}.ace-twilight .ace_invalid.ace_deprecated {text-decoration: underline;font-style: italic;color: #D2A8A1}.ace-twilight .ace_support {color: #9B859D}.ace-twilight .ace_fold {background-color: #AC885B;border-color: #F8F8F8}.ace-twilight .ace_support.ace_function {color: #DAD085}.ace-twilight .ace_list,.ace-twilight .ace_markup.ace_list,.ace-twilight .ace_storage {color: #F9EE98}.ace-twilight .ace_entity.ace_name.ace_function,.ace-twilight .ace_meta.ace_tag,.ace-twilight .ace_variable {color: #AC885B}.ace-twilight .ace_string {color: #8F9D6A}.ace-twilight .ace_string.ace_regexp {color: #E9C062}.ace-twilight .ace_comment {font-style: italic;color: #5F5A60}.ace-twilight .ace_variable {color: #7587A6}.ace-twilight .ace_xml-pe {color: #494949}.ace-twilight .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQERFpYLC1tf0PAAgOAnPnhxyiAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)})
@@ -0,0 +1,15 @@
+//= require ./jquery
+//= require ./jquery_ujs
+//= require ./list
+//= require ./stupidtable
+//= require ./jquery.stickytableheaders
+//= require ./selectize
+//= require ./highlight.pack
+//= require ./moment
+//= require ./daterangepicker
+//= require ./ace/ace
+//= require ./ace/ext-language_tools
+//= require ./ace/theme-twilight
+//= require ./ace/mode-sql
+//= require ./ace/snippets/text
+//= require ./ace/snippets/sql
Oops, something went wrong.

0 comments on commit febad48

Please sign in to comment.