work off today
This commit is contained in:
+155
-1
@@ -16,6 +16,160 @@ require File.expand_path('./../../lib/couchbase-setting', __FILE__)
|
||||
Bundler.require(*Rails.groups(assets: %w(development test user_app)))
|
||||
Bundler.require(:assets) if ENV['DEPLOY']=='yes'
|
||||
|
||||
# Bug in actionview error handling, remove for versions > 6.0.2.1
|
||||
module ActionView
|
||||
# = Action View Errors
|
||||
class ActionViewError < StandardError #:nodoc:
|
||||
end
|
||||
|
||||
class EncodingError < StandardError #:nodoc:
|
||||
end
|
||||
|
||||
class WrongEncodingError < EncodingError #:nodoc:
|
||||
def initialize(string, encoding)
|
||||
@string, @encoding = string, encoding
|
||||
end
|
||||
|
||||
def message
|
||||
@string.force_encoding(Encoding::ASCII_8BIT)
|
||||
"Your template was not saved as valid #{@encoding}. Please " \
|
||||
"either specify #{@encoding} as the encoding for your template " \
|
||||
"in your text editor, or mark the template with its " \
|
||||
"encoding by inserting the following as the first line " \
|
||||
"of the template:\n\n# encoding: <name of correct encoding>.\n\n" \
|
||||
"The source of your template was:\n\n#{@string}"
|
||||
end
|
||||
end
|
||||
|
||||
class MissingTemplate < ActionViewError #:nodoc:
|
||||
attr_reader :path
|
||||
|
||||
def initialize(paths, path, prefixes, partial, details, *)
|
||||
@path = path
|
||||
prefixes = Array(prefixes)
|
||||
template_type = if partial
|
||||
"partial"
|
||||
elsif /layouts/i.match?(path)
|
||||
"layout"
|
||||
else
|
||||
"template"
|
||||
end
|
||||
|
||||
if partial && path.present?
|
||||
path = path.sub(%r{([^/]+)$}, "_\\1")
|
||||
end
|
||||
searched_paths = prefixes.map { |prefix| [prefix, path].join("/") }
|
||||
|
||||
out = "Missing #{template_type} #{searched_paths.join(", ")} with #{details.inspect}. Searched in:\n"
|
||||
out += paths.compact.map { |p| " * #{p.to_s.inspect}\n" }.join
|
||||
super out
|
||||
end
|
||||
end
|
||||
|
||||
class Template
|
||||
# The Template::Error exception is raised when the compilation or rendering of the template
|
||||
# fails. This exception then gathers a bunch of intimate details and uses it to report a
|
||||
# precise exception message.
|
||||
class Error < ActionViewError #:nodoc:
|
||||
SOURCE_CODE_RADIUS = 3
|
||||
|
||||
# Override to prevent #cause resetting during re-raise.
|
||||
attr_reader :cause
|
||||
|
||||
def initialize(template)
|
||||
super($!.message)
|
||||
set_backtrace($!.backtrace)
|
||||
@cause = $!
|
||||
@template, @sub_templates = template, nil
|
||||
end
|
||||
|
||||
def file_name
|
||||
@template.identifier
|
||||
end
|
||||
|
||||
def sub_template_message
|
||||
if @sub_templates
|
||||
"Trace of template inclusion: " +
|
||||
@sub_templates.collect(&:inspect).join(", ")
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def source_extract(indentation = 0)
|
||||
return [] unless num = line_number
|
||||
num = num.to_i
|
||||
|
||||
source_code = @template.source.split("\n")
|
||||
|
||||
start_on_line = [ num - SOURCE_CODE_RADIUS - 1, 0 ].max
|
||||
end_on_line = [ num + SOURCE_CODE_RADIUS - 1, source_code.length].min
|
||||
|
||||
indent = end_on_line.to_s.size + indentation
|
||||
return [] unless source_code = source_code[start_on_line..end_on_line]
|
||||
|
||||
formatted_code_for(source_code, start_on_line, indent)
|
||||
end
|
||||
|
||||
def sub_template_of(template_path)
|
||||
@sub_templates ||= []
|
||||
@sub_templates << template_path
|
||||
end
|
||||
|
||||
def line_number
|
||||
@line_number ||=
|
||||
if file_name
|
||||
regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/
|
||||
$1 if message =~ regexp || backtrace.find { |line| line =~ regexp }
|
||||
end
|
||||
end
|
||||
|
||||
def annotated_source_code
|
||||
source_extract(4)
|
||||
end
|
||||
|
||||
private
|
||||
def source_location
|
||||
if line_number
|
||||
"on line ##{line_number} of "
|
||||
else
|
||||
"in "
|
||||
end + file_name
|
||||
end
|
||||
|
||||
def formatted_code_for(source_code, line_counter, indent)
|
||||
indent_template = "%#{indent}s: %s"
|
||||
source_code.map do |line|
|
||||
line_counter += 1
|
||||
indent_template % [line_counter, line]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TemplateError = Template::Error
|
||||
|
||||
class SyntaxErrorInTemplate < TemplateError #:nodoc
|
||||
def initialize(template, offending_code_string)
|
||||
@offending_code_string = offending_code_string
|
||||
super(template)
|
||||
end
|
||||
|
||||
def message
|
||||
<<~MESSAGE
|
||||
Encountered a syntax error while rendering template: check #{@offending_code_string}
|
||||
MESSAGE
|
||||
end
|
||||
|
||||
def annotated_source_code
|
||||
@offending_code_string.split("\n").map.with_index(1) { |line, index|
|
||||
indentation = " " * 4
|
||||
"#{index}:#{indentation}#{line}"
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require 'simply_stored'
|
||||
module SimplyStored
|
||||
module Couch
|
||||
@@ -133,7 +287,7 @@ module Qwaiter
|
||||
end
|
||||
end
|
||||
|
||||
config.middleware.insert_before 0, "Rack::Cors" do
|
||||
config.middleware.insert_before 0, Rack::Cors do
|
||||
allow do
|
||||
origins '*'
|
||||
#resource '/user/*', :headers => '*', :methods => '*' #[:get, :post, :options]
|
||||
|
||||
@@ -14,7 +14,7 @@ Qwaiter::Application.configure do
|
||||
config.action_controller.perform_caching = false
|
||||
config.action_controller.action_on_unpermitted_parameters = :log
|
||||
|
||||
config.ember.variant = :development
|
||||
#config.ember.variant = :development
|
||||
|
||||
config.action_controller.asset_host = "http://#{ENV['MOZO_LOCAL_IP'] || 'localhost'}:3000"
|
||||
# config.web_console.automount = true
|
||||
@@ -42,7 +42,9 @@ Qwaiter::Application.configure do
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
config.assets.logger = Logger.new('/dev/null')
|
||||
#config.assets.logger = Logger.new('/dev/null')
|
||||
#config.logger = Logger.new(STDOUT)
|
||||
#config.assets.logger = Logger.new(STDOUT)
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
module Qwaiter
|
||||
class FailureApp < Devise::FailureApp
|
||||
def respond
|
||||
if request.format.json?
|
||||
json_api_error_response
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
def json_api_error_response
|
||||
self.status = 401
|
||||
self.content_type = 'application/json'
|
||||
self.response_body = { errors: [{ status: '401', title: i18n_message }]}.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
Devise.setup do |config|
|
||||
# The secret key used by Devise. Devise uses this key to generate
|
||||
# random tokens. Changing this key will render invalid all existing
|
||||
@@ -250,10 +264,11 @@ Devise.setup do |config|
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
config.warden do |manager|
|
||||
manager.failure_app = Qwaiter::FailureApp
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module MustacheTemplateHandler
|
||||
def self.call(template)
|
||||
def self.call(template, source)
|
||||
binding.pry
|
||||
if template.locals.include? :locals
|
||||
"Mustache.render(#{template.source.inspect}, locals).html_safe"
|
||||
else
|
||||
|
||||
@@ -124,6 +124,7 @@ Qwaiter::Application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :suppliers, path: '/supplier' do
|
||||
get 'employee_and_supplier', controller: 'application'
|
||||
resources :suppliers do
|
||||
member do
|
||||
get :switch_to
|
||||
|
||||
Reference in New Issue
Block a user