[issue #274] Fixed file detection.
TODO. 1. Change MIME in editor 2. Change MIME sorting
This commit is contained in:
parent
396540ffe3
commit
d6d8410b0f
|
@ -305,6 +305,7 @@ table.tablesorter tbody td a .issue_title {
|
||||||
#output.formatted {
|
#output.formatted {
|
||||||
width: auto;
|
width: auto;
|
||||||
font-family: "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace;
|
font-family: "Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace;
|
||||||
|
color: #000000;
|
||||||
padding: 10px 5px 0px;
|
padding: 10px 5px 0px;
|
||||||
margin-left: 45px;
|
margin-left: 45px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,11 @@ module GitHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def choose_render_way(blob)
|
def choose_render_way(blob)
|
||||||
return :image if blob.mime_type.match(/image/)
|
return :image if blob.mime_type.match(/image/)
|
||||||
return :text if blob.mime_type.match(/text|xml|json/)
|
return :binary if blob.binary?
|
||||||
:binary
|
:text
|
||||||
|
# return :text if blob.mime_type.match(/text|xml|json/)
|
||||||
|
# :binary
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_encoding_to_site(string)
|
def force_encoding_to_site(string)
|
||||||
|
|
|
@ -53,5 +53,5 @@
|
||||||
:javascript
|
:javascript
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var text = $('#code').text().replace(/&/gi, '&');
|
var text = $('#code').text().replace(/&/gi, '&');
|
||||||
CodeMirror.runMode(text, "#{File.extname(@blob.name) == '.spec' ? 'text/x-rpm-spec' : @blob.mime_type}", document.getElementById("output"));
|
CodeMirror.runMode(text, "#{@blob.raw_mime_type.content_type}", document.getElementById("output"));
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,3 +13,6 @@ Rosa::Application.config.middleware.insert_before ::Grack::Handler, ::Grack::Aut
|
||||||
# Grit::Git.git_timeout = 60
|
# Grit::Git.git_timeout = 60
|
||||||
|
|
||||||
Dir[Rails.root.join("lib/ext/**/*.rb")].each {|f| require f}
|
Dir[Rails.root.join("lib/ext/**/*.rb")].each {|f| require f}
|
||||||
|
|
||||||
|
# add rpm spec as mime type for *.spec files
|
||||||
|
MIME::Types.add(MIME::Type.from_array(["text/x-rpm-spec", ['spec'], '8bit']))
|
||||||
|
|
|
@ -284,11 +284,11 @@ ActiveRecord::Schema.define(:version => 20120303171802) do
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "ancestry"
|
t.string "ancestry"
|
||||||
t.boolean "has_issues", :default => true
|
t.boolean "has_issues", :default => true
|
||||||
|
t.boolean "has_wiki", :default => false
|
||||||
t.string "srpm_file_name"
|
t.string "srpm_file_name"
|
||||||
t.string "srpm_content_type"
|
t.string "srpm_content_type"
|
||||||
t.integer "srpm_file_size"
|
t.integer "srpm_file_size"
|
||||||
t.datetime "srpm_updated_at"
|
t.datetime "srpm_updated_at"
|
||||||
t.boolean "has_wiki", :default => false
|
|
||||||
t.string "default_branch", :default => "master"
|
t.string "default_branch", :default => "master"
|
||||||
t.boolean "is_rpm", :default => true
|
t.boolean "is_rpm", :default => true
|
||||||
end
|
end
|
||||||
|
@ -309,7 +309,6 @@ ActiveRecord::Schema.define(:version => 20120303171802) do
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
|
add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false
|
||||||
add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false
|
|
||||||
|
|
||||||
create_table "relations", :force => true do |t|
|
create_table "relations", :force => true do |t|
|
||||||
t.integer "object_id"
|
t.integer "object_id"
|
||||||
|
@ -369,6 +368,7 @@ ActiveRecord::Schema.define(:version => 20120303171802) do
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
@ -376,7 +376,6 @@ ActiveRecord::Schema.define(:version => 20120303171802) do
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
t.datetime "reset_password_sent_at"
|
|
||||||
t.integer "own_projects_count", :default => 0, :null => false
|
t.integer "own_projects_count", :default => 0, :null => false
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
t.string "site"
|
t.string "site"
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# -*- ruby encoding: utf-8 -*-
|
||||||
|
|
||||||
|
module Grit
|
||||||
|
class Blob
|
||||||
|
|
||||||
|
DEFAULT_RAW_MIME_TYPE = MIME::Types[DEFAULT_MIME_TYPE].first
|
||||||
|
|
||||||
|
delegate :binary?, :ascii?, :encoding, :to => :raw_mime_type
|
||||||
|
|
||||||
|
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
|
||||||
|
@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 ||= MIME::Types.type_for(self.name) rescue [DEFAULT_RAW_MIME_TYPE]
|
||||||
|
@associated_mimes = [DEFAULT_RAW_MIME_TYPE] if @associated_mimes.empty?
|
||||||
|
@associated_mimes
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
require './lib/grit/repo.rb'
|
require './lib/grit/repo.rb'
|
||||||
require './lib/grit/diff.rb'
|
require './lib/grit/diff.rb'
|
||||||
|
require './lib/grit/blob.rb'
|
||||||
|
|
Loading…
Reference in New Issue