Merge branch '369-remove_codemirror' into 369-bootstrap
Conflicts: config/environments/production.rb
This commit is contained in:
commit
ae7de6776d
2
Gemfile
2
Gemfile
|
@ -92,6 +92,8 @@ gem 'font-awesome-rails'
|
|||
|
||||
gem 'sitemap_generator'
|
||||
|
||||
gem 'codemirror-rails', '~> 4.0'
|
||||
|
||||
group :production do
|
||||
gem "airbrake", '~> 3.1.2'
|
||||
gem 'bluepill', '~> 0.0.60', require: false
|
||||
|
|
|
@ -128,6 +128,8 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
cocaine (0.5.3)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
codemirror-rails (4.0)
|
||||
railties (>= 3.0, < 5)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (4.0.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
|
@ -534,6 +536,7 @@ DEPENDENCIES
|
|||
capistrano
|
||||
capistrano_colors
|
||||
charlock_holmes (~> 0.6.9)
|
||||
codemirror-rails (~> 4.0)
|
||||
coffee-rails (~> 4.0.1)
|
||||
compass-rails (~> 1.1.6)
|
||||
creole
|
||||
|
|
|
@ -217,7 +217,7 @@ table.blob td.lines pre {
|
|||
|
||||
textarea#code {
|
||||
width: 845px;
|
||||
resize: none;
|
||||
resize: vertical;
|
||||
height: 30em;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
= javascript_include_tag 'codemirror_editor'
|
||||
= stylesheet_link_tag 'codemirror'
|
||||
|
||||
%h3= t("layout.projects.files_in_project")
|
||||
.files
|
||||
.l= render 'whereami'
|
||||
|
@ -21,7 +24,7 @@
|
|||
$(function() {
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
lineNumbers: true,
|
||||
mode: '#{@blob.raw_mime_type.content_type}'
|
||||
mode: '#{@blob.raw_mime_type}'
|
||||
});
|
||||
$(".CodeMirror").resizable({
|
||||
stop: function() { editor.refresh(); },
|
||||
|
|
|
@ -63,7 +63,9 @@ Rosa::Application.configure do
|
|||
config.assets.digest = true
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js new_application.css new_application.js)
|
||||
config.assets.precompile +=
|
||||
%w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js
|
||||
codemirror_editor.js codemirror.css new_application.css new_application.js)
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
|
|
|
@ -62,7 +62,9 @@ Rosa::Application.configure do
|
|||
config.assets.digest = true
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js)
|
||||
config.assets.precompile +=
|
||||
%w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js
|
||||
codemirror_editor.js codemirror.css)
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
|
|
|
@ -43,61 +43,17 @@ module Grit
|
|||
end
|
||||
end
|
||||
|
||||
# def file_mime_type
|
||||
# @file_mime_type ||= data.file_type(:mime_type)
|
||||
# end
|
||||
#
|
||||
# def text?
|
||||
# file_mime_type =~ /^text\// # not binary?
|
||||
# end
|
||||
#
|
||||
# def binary?
|
||||
# not text? # file_mime_type !~ /^text\//
|
||||
# # s = data.split(//); ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30 # works only for latin chars
|
||||
# end
|
||||
#
|
||||
# def image?
|
||||
# mime_type.match(/image/)
|
||||
# end
|
||||
|
||||
DEFAULT_RAW_MIME_TYPE = MIME::Types[DEFAULT_MIME_TYPE].first
|
||||
|
||||
def mime_type_with_class_store
|
||||
set_associated_mimes
|
||||
@associated_mimes.first.simplified
|
||||
end
|
||||
alias_method_chain :mime_type, :class_store
|
||||
|
||||
attr_accessor :raw_mime_type
|
||||
def raw_mime_type
|
||||
set_associated_mimes
|
||||
@raw_mime_type = @associated_mimes.first || DEFAULT_RAW_MIME_TYPE
|
||||
return @raw_mime_type if @raw_mime_type.present?
|
||||
if mime_type == 'text/rpm-spec'
|
||||
@raw_mime_type = 'text/x-rpm-spec'
|
||||
else
|
||||
@raw_mime_type = Linguist::Language.detect(name, data).try(:lexer).try(:mimetypes).try(:first)
|
||||
@raw_mime_type ||= DEFAULT_MIME_TYPE
|
||||
@raw_mime_type.gsub!('application', 'text')
|
||||
@raw_mime_type
|
||||
end
|
||||
|
||||
def raw_mime_types
|
||||
set_associated_mimes
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# store all associated MIME::Types inside class
|
||||
def set_associated_mimes
|
||||
@associated_mimes ||= []
|
||||
if @associated_mimes.empty?
|
||||
guesses = MIME::Types.type_for(self.name) rescue [DEFAULT_RAW_MIME_TYPE]
|
||||
guesses = [DEFAULT_RAW_MIME_TYPE] if guesses.empty?
|
||||
|
||||
@associated_mimes = guesses.sort{|a,b| mime_sort(a, b)}
|
||||
end
|
||||
@associated_mimes
|
||||
end
|
||||
|
||||
# TODO make more clever function
|
||||
def mime_sort(a,b)
|
||||
return 0 if a.media_type == b.media_type and a.registered? == b.registered?
|
||||
return -1 if a.media_type == 'text' and !a.registered?
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
//= require codemirror
|
||||
|
||||
//= require codemirror/modes/apl
|
||||
//= require codemirror/modes/asterisk
|
||||
//= require codemirror/modes/clike
|
||||
//= require codemirror/modes/clojure
|
||||
//= require codemirror/modes/cobol
|
||||
//= require codemirror/modes/coffeescript
|
||||
//= require codemirror/modes/commonlisp
|
||||
//= require codemirror/modes/css
|
||||
//= require codemirror/modes/d
|
||||
//= require codemirror/modes/diff
|
||||
//= require codemirror/modes/dtd
|
||||
//= require codemirror/modes/ecl
|
||||
//= require codemirror/modes/eiffel
|
||||
//= require codemirror/modes/erlang
|
||||
//= require codemirror/modes/fortran
|
||||
//= require codemirror/modes/gas
|
||||
//= require codemirror/modes/gfm
|
||||
//= require codemirror/modes/gherkin
|
||||
//= require codemirror/modes/go
|
||||
//= require codemirror/modes/groovy
|
||||
//= require codemirror/modes/haml
|
||||
//= require codemirror/modes/haskell
|
||||
//= require codemirror/modes/haxe
|
||||
//= require codemirror/modes/htmlembedded
|
||||
//= require codemirror/modes/htmlmixed
|
||||
//= require codemirror/modes/http
|
||||
//= require codemirror/modes/jade
|
||||
//= require codemirror/modes/javascript
|
||||
//= require codemirror/modes/jinja2
|
||||
//= require codemirror/modes/julia
|
||||
//= require codemirror/modes/livescript
|
||||
//= require codemirror/modes/lua
|
||||
//= require codemirror/modes/markdown
|
||||
//= require codemirror/modes/mirc
|
||||
//= require codemirror/modes/mllike
|
||||
//= require codemirror/modes/nginx
|
||||
//= require codemirror/modes/ntriples
|
||||
//= require codemirror/modes/octave
|
||||
//= require codemirror/modes/pascal
|
||||
//= require codemirror/modes/pegjs
|
||||
//= require codemirror/modes/perl
|
||||
//= require codemirror/modes/php
|
||||
//= require codemirror/modes/pig
|
||||
//= require codemirror/modes/properties
|
||||
//= require codemirror/modes/puppet
|
||||
//= require codemirror/modes/python
|
||||
//= require codemirror/modes/q
|
||||
//= require codemirror/modes/r
|
||||
//= require codemirror/modes/rpm
|
||||
//= require codemirror/modes/rst
|
||||
//= require codemirror/modes/ruby
|
||||
//= require codemirror/modes/rust
|
||||
//= require codemirror/modes/sass
|
||||
//= require codemirror/modes/scheme
|
||||
//= require codemirror/modes/shell
|
||||
//= require codemirror/modes/sieve
|
||||
//= require codemirror/modes/smalltalk
|
||||
//= require codemirror/modes/smarty
|
||||
//= require codemirror/modes/smartymixed
|
||||
//= require codemirror/modes/solr
|
||||
//= require codemirror/modes/sparql
|
||||
//= require codemirror/modes/sql
|
||||
//= require codemirror/modes/stex
|
||||
//= require codemirror/modes/tcl
|
||||
//= require codemirror/modes/tiddlywiki
|
||||
//= require codemirror/modes/tiki
|
||||
//= require codemirror/modes/toml
|
||||
//= require codemirror/modes/turtle
|
||||
//= require codemirror/modes/vb
|
||||
//= require codemirror/modes/vbscript
|
||||
//= require codemirror/modes/velocity
|
||||
//= require codemirror/modes/verilog
|
||||
//= require codemirror/modes/xml
|
||||
//= require codemirror/modes/xquery
|
||||
//= require codemirror/modes/yaml
|
||||
//= require codemirror/modes/z80
|
Loading…
Reference in New Issue