refactor: repo (#1070)

This commit is contained in:
Mo
2022-06-07 07:18:41 -05:00
committed by GitHub
parent 4c65784421
commit f4ef63693c
1102 changed files with 5786 additions and 3366 deletions

View File

@@ -0,0 +1,2 @@
---
BUNDLE_PATH: "vendor/bundle"

View File

@@ -0,0 +1,36 @@
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/scm/git-with-submodules"
install_plugin Capistrano::SCM::Git::WithSubmodules
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
require 'capistrano/passenger'
# require 'capistrano/sidekiq'
# require "whenever/capistrano" # Update crontab on deploy
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

View File

@@ -0,0 +1,53 @@
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.1.7'
gem 'sass'
gem "non-stupid-digest-assets"
gem 'secure_headers'
gem 'uglifier'
gem 'rack-cors', :require => 'rack/cors'
gem 'dotenv-rails'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Used for 'respond_to' feature
gem 'responders', '~> 2.0'
gem 'tzinfo-data'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '3.5.1'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'puma'
gem 'haml'
# Deployment tools
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-passenger', '>= 0.2.0'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano-sidekiq'
gem 'capistrano-git-with-submodules', '~> 2.0'
end
gem "lograge", "~> 0.11.2"
gem "newrelic_rpm", "~> 7.0"

View File

@@ -0,0 +1,232 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (8.0.0)
bindex (0.8.1)
builder (3.2.4)
byebug (11.1.3)
capistrano (3.16.0)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.0.1)
capistrano (~> 3.1)
capistrano-git-with-submodules (2.0.4)
capistrano (~> 3.7)
capistrano-passenger (0.2.1)
capistrano (~> 3.0)
capistrano-rails (1.6.1)
capistrano (~> 3.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano-sidekiq (2.0.0)
capistrano (>= 3.9.0)
capistrano-bundler
sidekiq (>= 6.0)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crass (1.0.6)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.10.0)
execjs (2.8.1)
ffi (1.15.5)
ffi (1.15.5-x64-mingw32)
globalid (1.0.0)
activesupport (>= 5.0)
haml (5.2.2)
temple (>= 0.8.0)
tilt
i18n (1.10.0)
concurrent-ruby (~> 1.0)
json (1.8.6)
lograge (0.11.2)
actionpack (>= 4)
activesupport (>= 4)
railties (>= 4)
request_store (~> 1.0)
loofah (2.14.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.7.1)
minitest (5.15.0)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
newrelic_rpm (7.2.0)
nio4r (2.5.8)
nokogiri (1.13.1)
mini_portile2 (~> 2.7.0)
racc (~> 1.4)
nokogiri (1.13.1-x64-mingw32)
racc (~> 1.4)
nokogiri (1.13.1-x86_64-darwin)
racc (~> 1.4)
non-stupid-digest-assets (1.0.9)
sprockets (>= 2.0)
puma (5.6.2)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (13.0.6)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (4.3.0)
redis (4.6.0)
request_store (1.5.1)
rack (>= 1.4)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
secure_headers (6.3.3)
sidekiq (6.4.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
spring (3.1.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.21.2)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.8.2)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo-data (1.2021.5)
tzinfo (>= 1.0.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
PLATFORMS
ruby
x64-mingw32
x86_64-darwin-18
DEPENDENCIES
byebug
capistrano
capistrano-bundler
capistrano-git-with-submodules (~> 2.0)
capistrano-passenger (>= 0.2.0)
capistrano-rails
capistrano-rvm
capistrano-sidekiq
dotenv-rails
haml
lograge (~> 0.11.2)
newrelic_rpm (~> 7.0)
non-stupid-digest-assets
puma
rack-cors
rails (= 5.1.7)
responders (~> 2.0)
sass
sdoc (~> 0.4.0)
secure_headers
spring
tzinfo-data
uglifier
web-console (= 3.5.1)
BUNDLED WITH
2.3.15

View File

@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks

View File

@@ -0,0 +1,46 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
after_action :set_csrf_cookie
after_action :allow_iframe
layout :false
def app
end
rescue_from ActionView::MissingTemplate do |exception|
end
def route_not_found
render :json => {:error => {:message => "Not found."}}, :status => 404
end
protected
def allow_iframe
response.headers.except! 'X-Frame-Options'
end
def set_csrf_cookie
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
def append_info_to_payload(payload)
super
unless payload[:status]
return
end
payload[:level] = 'INFO'
if payload[:status] >= 500
payload[:level] = 'ERROR'
elsif payload[:status] >= 400
payload[:level] = 'WARN'
end
end
end

View File

@@ -0,0 +1,5 @@
class HealthCheckController < ApplicationController
def index
render :plain => "OK"
end
end

View File

@@ -0,0 +1,10 @@
class StandardNotesFormatter < ActiveSupport::Logger::SimpleFormatter
def call(severity, timestamp, _progname, message)
{
level: severity,
time: timestamp,
message: message,
ddsource: ['ruby'],
}.to_json + "\n"
end
end

View File

@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<link rel="canonical" href="<%= ENV['APP_HOST'] %>" />
<link href="favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180"></link>
<link href="favicon/favicon-32x32.png" rel="icon" sizes="32x32" type="image/png"></link>
<link href="favicon/favicon-16x16.png" rel="icon" sizes="16x16" type="image/png"></link>
<link href="manifest.webmanifest" rel="manifest"></link>
<link color="#5bbad5" href="favicon/safari-pinned-tab.svg" rel="mask-icon"></link>
<meta name="theme-color" content="#ffffff">
<meta content="Standard Notes" name="apple-mobile-web-app-title"/>
<meta content="Standard Notes" name="application-name"/>
<base href="/"></base>
<title>Notes · Standard Notes</title>
<meta name="description" content="Standard Notes is an easy-to-use encrypted note-taking app for digitalists and professionals. Capture your notes, documents, and life's work all in one place."/>
<meta name="twitter:title" content="Standard Notes, an end-to-end encrypted notes app."/>
<meta name="twitter:description" content="Standard Notes is an easy-to-use encrypted note-taking app for digitalists and professionals. Capture your notes, documents, and life's work all in one place."/>
<meta name="twitter:site" content="@standardnotes"/>
<meta name="twitter:card" content="summary"/>
<meta name="og:title" content="Standard Notes, an end-to-end encrypted notes app."/>
<meta name="og:description" content="Standard Notes is an easy-to-use encrypted note-taking app for digitalists and professionals. Capture your notes, documents, and life's work all in one place."/>
<script>
window.defaultSyncServer = "<%= ENV['DEFAULT_SYNC_SERVER'] %>";
window.defaultFilesHost = "<%= ENV['DEFAULT_FILES_HOST'] %>";
window.enabledUnfinishedFeatures = "<%= ENV['ENABLE_UNFINISHED_FEATURES'] %>" === 'true';
window.websocketUrl = "<%= ENV['WEBSOCKET_URL'] %>";
window.purchaseUrl = "<%= ENV['PURCHASE_URL'] %>";
window.plansUrl = "<%= ENV['PLANS_URL'] %>";
window.dashboardUrl = "<%= ENV['DASHBOARD_URL'] %>";
</script>
<% if Rails.env.development? %>
<%= javascript_include_tag "app.js", debug: true %>
<% else %>
<%= javascript_include_tag "app.js", debug: false %>
<% end %>
<%= stylesheet_link_tag "app.css", media: "all", debug: false %>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Standard Notes</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

3
packages/web-server/bin/bundle Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
packages/web-server/bin/rails Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

4
packages/web-server/bin/rake Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

34
packages/web-server/bin/setup Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

15
packages/web-server/bin/spring Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require "rubygems"
require "bundler"
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
gem "spring", match[1]
require "spring/binstub"
end
end

29
packages/web-server/bin/update Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

View File

@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@@ -0,0 +1,91 @@
require_relative 'boot'
# require 'rails/all'
require "active_model/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "active_job/railtie" # Only for Rails >= 4.2
require "action_cable/engine" # Only for Rails >= 5.0
require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Web
class Application < Rails::Application
# Cross-Origin Resource Sharing (CORS) for Rack compatible web applications.
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*', :headers => :any, :methods => [:get, :post, :put, :patch, :delete, :options], :expose => ['Access-Token', 'Client', 'UID']
end
end
# config.action_dispatch.default_headers = {
# 'X-Frame-Options' => 'ALLOWALL'
# }
SecureHeaders::Configuration.default do |config|
# Handled by server
config.x_frame_options = SecureHeaders::OPT_OUT
config.x_content_type_options = SecureHeaders::OPT_OUT
config.x_xss_protection = SecureHeaders::OPT_OUT
config.hsts = SecureHeaders::OPT_OUT
config.csp = {
# "meta" values. these will shape the header, but the values are not included in the header.
preserve_schemes: true, # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
# directive values: these values will directly translate into source directives
default_src: %w(https: 'self'),
base_uri: %w('self'),
block_all_mixed_content: false, # see http://www.w3.org/TR/mixed-content/
child_src: ["*", "blob:"],
frame_src: ["*", "blob:"],
connect_src: ["*", 'data:'],
font_src: ['*', "'self'", 'data:'],
form_action: %w('self'),
frame_ancestors: ["*", "*.standardnotes.com", "*.standardnotes.org"],
img_src: ["'self'", '* data:', 'blob:'],
manifest_src: %w('self'),
media_src: %w('self' blob: *.standardnotes.com),
object_src: %w('self' blob: *.standardnotes.com),
plugin_types: %w(),
script_src: %w('self' 'unsafe-inline' 'unsafe-eval'),
style_src: %w(* 'unsafe-inline'),
upgrade_insecure_requests: false, # see https://www.w3.org/TR/upgrade-insecure-requests/
}
end
# config.middleware.use Rack::Deflater
config.middleware.insert_before(Rack::Sendfile, Rack::Deflater)
# Disable auto creation of additional resources with "rails generate"
config.generators do |g|
g.test_framework false
g.view_specs false
g.helper_specs false
g.stylesheets = false
g.javascripts = false
g.helper = false
end
config.action_mailer.default_url_options = { host: ENV['APP_HOST'] }
# SMTP settings
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => ENV['SMTP_HOST'],
:port => ENV['SMTP_PORT'],
:domain => ENV['SMTP_DOMAIN'],
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:authentication => 'login',
:enable_starttls_auto => true # detects and uses STARTTLS
}
end
end

View File

@@ -0,0 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.

View File

@@ -0,0 +1,15 @@
default: &default
key_path: /path/to/key.pem
repo_url: https://github.com/sn-project/sn-web-client.git
user: ssh_username
staging:
<<: *default
server: staging.yourdomain.com
branch: staging
deploy_to: ~/sn-staging-client
production:
<<: *default
server: yourdomain.com
deploy_to: ~/sn-prod-client

View File

@@ -0,0 +1,40 @@
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: <%= ENV['DB_USERNAME'] %>
password: <%= ENV['DB_PASSWORD'] %>
database: <%= ENV['DB_DATABASE'] %>
host: <%= ENV['DB_HOST'] %>
port: <%= ENV['DB_PORT'] %>
development:
<<: *default
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
staging:
<<: *default
production:
<<: *default

View File

@@ -0,0 +1,49 @@
CAP_CONFIG = YAML.load_file("config/cap.yml")
set :application, 'standard-notes'
set :repo_url, CAP_CONFIG["default"]["repo_url"]
# Default branch is :master
set :branch, `git rev-parse --abbrev-ref main`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'
# Default value for :format is :airbrussh.
# set :format, :airbrussh
# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
set :linked_files, fetch(:linked_files, []).push('.env')
# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'public/uploads')
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 5 do
# Here we can do anything such as:
within release_path do
end
end
end
end
set :ssh_options, {
keys: %W( #{CAP_CONFIG['default']['key_path']} ),
forward_agent: false,
auth_methods: %w(publickey)
}

View File

@@ -0,0 +1,63 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
server CAP_CONFIG['production']['server'], user: CAP_CONFIG['production']['user'], roles: %w{app db web}
set :deploy_to, CAP_CONFIG['production']['deploy_to']
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }

View File

@@ -0,0 +1,65 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
server CAP_CONFIG['staging']['server'], user: CAP_CONFIG['staging']['user'], roles: %w{app db web}
set :branch, CAP_CONFIG['staging']['branch']
set :deploy_to, CAP_CONFIG['staging']['deploy_to']
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }

View File

@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View File

@@ -0,0 +1,64 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# config.assets.js_compressor = Uglifier.new(mangle: false)\
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
config.reload_classes_only_on_change = true
# Do not eager load code on boot.
config.eager_load = false
MAX_LOG_MEGABYTES = 50
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
end
config.colorize_logging = false
config.logger.formatter = StandardNotesFormatter.new
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.public_file_server.enabled = true
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
# config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
config.assets.logger = false
config.assets.quiet = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@@ -0,0 +1,94 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
MAX_LOG_MEGABYTES = 50
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
end
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'INFO').to_sym
config.colorize_logging = false
config.logger.formatter = StandardNotesFormatter.new
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.public_file_server.enabled = true
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Compress JavaScripts and CSS.
config.assets.compress = true
# config.assets.js_compressor = Uglifier.new(mangle: false)
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
config.assets.logger = false
config.assets.quiet = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
ActiveSupport::Deprecation.silenced = true
# Do not dump schema after migrations.
# config.active_record.dump_schema_after_migration = false
end

View File

@@ -0,0 +1,79 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
MAX_LOG_MEGABYTES = 50
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, 1, MAX_LOG_MEGABYTES * 1024 * 1024)
if ENV["RAILS_LOG_TO_STDOUT"].present?
config.logger = ActiveSupport::Logger.new(STDOUT)
end
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = true
config.action_controller.perform_caching = true
# Compress JavaScripts and CSS.
config.assets.compress = true
# config.assets.js_compressor = Uglifier.new(mangle: false)
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
# config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Do not dump schema after migrations.
# config.active_record.dump_schema_after_migration = false
end

View File

@@ -0,0 +1,42 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@@ -0,0 +1,6 @@
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )

View File

@@ -0,0 +1,6 @@
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.1'
Rails.application.config.assets.paths << Rails.root.join('..', 'web', 'dist')
Rails.application.config.assets.precompile += ['app.js', 'app.css']

View File

@@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@@ -0,0 +1,9 @@
# fix for JSON deprecation warnings. See: https://github.com/flori/json/issues/399#issuecomment-734863279
module JSON
module_function
def parse(source, opts = {})
Parser.new(source, **opts).parse
end
end

View File

@@ -0,0 +1,7 @@
Rails.application.configure do
config.lograge.enabled = true
# Generate log in JSON
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.ignore_actions = ['HealthCheckController#index']
end

View File

@@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf

View File

@@ -0,0 +1,23 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Rails 5.0 release notes for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
# Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true

View File

@@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_sn_session'

View File

@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

View File

@@ -0,0 +1,23 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@@ -0,0 +1,53 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
#!/usr/bin/env puma
# start puma with:
# RAILS_ENV=production bundle exec puma -C ./config/puma.rb
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

View File

@@ -0,0 +1,7 @@
Rails.application.routes.draw do
get "/healthcheck" => "health_check#index"
get '*unmatched_route', to: 'application#route_not_found'
root 'application#app'
end

View File

@@ -0,0 +1,25 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: e3336569c7fc35724ab2f19ca4024f70f20a372ffccf619064007593aa7e4ad0afafb88eb4c03620bdb10f3e975b0240a95c8cfc8b7664750208b9cf9b039f01
test:
secret_key_base: 7eedf23ca7967ab47b0a7e1c1f3bbf1f804f0d76ae7b27e8a37e9cbbffad95f099901f5b4821f391bcdeb104d2e0b1333cf56d485ad3ee41bc7fad2fbaf7ec3e
staging:
secret_key_base: fd5255d5cc6a90944a292df8041cd125e20f28fd62cabf092133ce569457e7399e90294dc0413a43ed7e15f8414593632ff6b41b34d6361fab2069f6351958f6
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

View File

@@ -0,0 +1,6 @@
%w(
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }

View File

@@ -0,0 +1,15 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161128001641) do
end

View File

@@ -0,0 +1,7 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)

View File

View File

View File

View File

@@ -0,0 +1,19 @@
{
"name": "@standardnotes/web-server",
"version": "1.0.0",
"license": "AGPL-3.0-or-later",
"author": "Standard Notes",
"description": "Ruby on Rails web server for hosting the web application",
"engines": {
"node": ">=12.19.0 <17.0.0"
},
"scripts": {
"start": "bundle exec rails s -b 0.0.0.0",
"start:no-binding": "bundle exec rails s",
"clean": "bundle exec rails assets:clobber",
"build": "bundle install && bundle exec rails assets:precompile"
},
"dependencies": {
"@standardnotes/web": "^3.20.4"
}
}

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<div>
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,102 @@
{
"org.standardnotes.theme-midnight": {
"version": "1.2.8",
"base64": "df7838f1214a0efdc3d0d5302b04fb6f33384dd9431edcd2d1baabfe0808b681",
"binary": "511de23e2f0148fbf27523f550dea8aeb34d95690ff56607b6aec1c9af8df91b"
},
"org.standardnotes.theme-futura": {
"version": "1.2.9",
"base64": "44007ca0d84197140a8ecfdef08c0796187c97e8c8284ff2c394f2d37d4483d3",
"binary": "df8be9afe4ed6cd315e5c0b09aa11a61c769dcdf352bc1a3000a1cf0be285072"
},
"org.standardnotes.theme-solarized-dark": {
"version": "1.2.7",
"base64": "553b9b8717c237d91f20e287f035beb4cb5714c4e4d89fb2ec286d45b5d3457d",
"binary": "05d8edc7f4d686ed95bf6f2965cddf6256a674a9289d54fb6f3e6dae722f7a78"
},
"org.standardnotes.theme-autobiography": {
"version": "1.0.4",
"base64": "6bdd4fb649353d9b90990c579470cbb3ab69756b3e256f328ac195996726583f",
"binary": "32a8712b870c68726860b31cf2b2b7c62d80cb167fe5aa7ca7c76f89c39afca1"
},
"org.standardnotes.theme-focus": {
"version": "1.2.9",
"base64": "dcb86b825d13a0fdb0ce3a05a711158535334e8a04069056d96211ab80ca02b1",
"binary": "1516d80ab4a1c47f3b09b97463fa744b3d74478ca2f817c0735f47768ace68a1"
},
"org.standardnotes.theme-titanium": {
"version": "1.2.7",
"base64": "5ec4f59d09fae3f8bc62279eac15b6b7fcb00ba1324a7316bf5947ce543f7458",
"binary": "1cbe4b0944a0f614d031e0d869bf70c7aad369ee67a8c11e20962759fcb50c05"
},
"org.standardnotes.theme-dynamic": {
"version": "1.0.4",
"base64": "92038664655c6cb1d6b422b9546da1a98da58b0251394cf2a485aed9b1774c07",
"binary": "d05185aca67768f35227565dacce030fdff233563f119781baaf4e95f9198115"
},
"org.standardnotes.code-editor": {
"version": "1.3.12",
"base64": "79e1d65a478ef91626fbe0d6e1ead11106d1e7619d1bb54e7081987ab396c2ef",
"binary": "470ced1e16fbbc83c0e280971da388b1bbc6c90f2c489428fe86350bcc6baece"
},
"org.standardnotes.bold-editor": {
"version": "1.3.5",
"base64": "bcecfd1a6ee1909c9f484890cf58d6d52479f8d33c16e1d5d916d1a78a75b90f",
"binary": "84d6ca88665d4d6a1aeb456f8acce1a662bfe4550128aac1fb748abed974f236"
},
"org.standardnotes.plus-editor": {
"version": "1.6.1",
"base64": "741c77ab437b17e9e76755485b828a8530bfc0c713258e72374a6fced61a3aef",
"binary": "02da20d1969bc2cc9bc9e164bcd6f993183747c8d6c3edae814fa12789950544"
},
"org.standardnotes.simple-markdown-editor": {
"version": "1.4.2",
"base64": "765b52c459dddf8b7fbc70068526af51218d09ae5c1bca783ea0ecdc0cf5228b",
"binary": "bed9d0353a2b3ed721ea1f1ba3eba0f2452ffb730d436821148ee330ab5af651"
},
"org.standardnotes.advanced-markdown-editor": {
"version": "1.5.0",
"base64": "efec7575f3c6a9bbc5a7be555f6a1738af10c4d4144f146265e0a5e7ea49796d",
"binary": "b7c8874bb58be1d17103511f19325530f461e2b2cb3bbac87719525662907504"
},
"org.standardnotes.minimal-markdown-editor": {
"version": "1.3.9",
"base64": "cd84837e2591443fa5d331c069b2cf73d7bd1c493cda2d42695f7115e3850b30",
"binary": "cd3f7720c8d915d640291f06b4d23c2fc19071a38535aa3e3a89df8f96716ce7"
},
"org.standardnotes.fancy-markdown-editor": {
"version": "1.3.6",
"base64": "4601e4c4a1a5e0290fcfbd2d1f3389683d55237b751cc2953053a4ee7f997022",
"binary": "d8060e0eb8dc727339329be5e5150c077e2795ff2145521dc90a38717eea5d3c"
},
"org.standardnotes.simple-task-editor": {
"version": "1.3.10",
"base64": "dfcfa7373928a940b94f0779d1995698b9cae8ce770a2d7aa8ac6c0937b3a4e2",
"binary": "94e0153beb4c9e97d96ac7b9202b6f46c4cfd560075dda183258d5353e61e0a3"
},
"org.standardnotes.token-vault": {
"version": "2.0.10",
"base64": "65540f4e291ea5d00ecda1fc6a7c876ec33cdf41fabc4802eb675f92a4fcaea3",
"binary": "5db0caea04c8db86c8bdd99d973c7b9021a2cfaa5a9d7728c4a4775e22ae7c30"
},
"org.standardnotes.standard-sheets": {
"version": "1.4.4",
"base64": "9f583da4e61a6da1422a96ab4d1ba2835421e09d2de3c5efee2e8391431e045e",
"binary": "2464c763615910476edea2869418352b727f39847280d6f7745e07f19541f3e1"
},
"org.standardnotes.file-safe": {
"version": "2.0.10",
"base64": "e1d3ef7f1a4c0365a2b4037376813c4e46e8f54b61ecc3ed6a7346b27aa753ee",
"binary": "abfa7368ea3cabc9f6896d4070c899025b73378000bc67c3a607f88e048663a7"
},
"org.standardnotes.folders": {
"version": "1.3.8",
"base64": "e895b21645264f991cd212dbf3207731ecffab203f540f7145edad4601e6f6a2",
"binary": "88d4b9a6ff94b1f6cba884787e051cda3cd8073022984b63f7d3b13157aa6e2a"
},
"org.standardnotes.markdown-visual-editor": {
"version": "1.0.6",
"base64": "13497d3939fbec67cf0baa0f7c182112f0d13474a3e7f4750790823f78688a47",
"binary": "fc6e37d7250d14b245facb760aece51d006fd321d9ac2f153c5a571565411311"
}
}

View File

@@ -0,0 +1,278 @@
body, html {
font-family: sans-serif;
font-size: var(--sn-stylekit-base-font-size);
background-color: transparent;
}
* {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.mobile .editor-toolbar, .mobile .editor-toolbar.fullscreen, .mac-web .editor-toolbar, .mac-web .editor-toolbar.fullscreen, .mac-desktop .editor-toolbar, .mac-desktop .editor-toolbar.fullscreen {
overflow-x: auto;
}
.editor-toolbar.fullscreen, .CodeMirror-fullscreen {
position: absolute !important;
}
.CodeMirror {
border-left: 0;
border-right: 0;
border-bottom: 0;
background-color: transparent;
border: none;
font-size: var(--sn-stylekit-font-size-editor);
-webkit-overflow-scrolling: touch;
}
.editor-toolbar, .editor-toolbar.fullscreen {
background-color: var(--sn-stylekit-contrast-background-color);
border-bottom: 1px solid var(--sn-stylekit-border-color);
overflow: visible;
}
.editor-toolbar::before, .editor-toolbar::after, .editor-toolbar.fullscreen::before, .editor-toolbar.fullscreen::after {
background: none !important;
}
.editor-toolbar i.separator {
border-left-color: var(--sn-stylekit-contrast-border-color);
border-right-color: var(--sn-stylekit-contrast-background-color);
}
.editor-toolbar button {
color: var(--sn-stylekit-info-color) !important;
outline: none;
border-radius: 0;
font-size: var(--sn-stylekit-base-font-size);
}
.editor-toolbar button.active, .editor-toolbar button:hover {
border-color: transparent;
background: var(--sn-stylekit-background-color);
}
.editor-toolbar.disabled-for-preview button:not(.no-disable) {
background: inherit;
}
.editor-preview-active, .editor-preview-active-side {
background-color: var(--sn-stylekit-contrast-background-color);
border: 0;
border-left: 1px solid var(--sn-stylekit-border-color);
color: var(--sn-stylekit-contrast-foreground-color);
font-size: var(--sn-stylekit-font-size-editor);
padding: 10px 15px;
}
.editor-preview-active a, .editor-preview-active-side a {
color: var(--sn-stylekit-info-color);
}
.editor-preview-active img, .editor-preview-active-side img {
max-width: 100%;
}
.editor-preview-active pre, .editor-preview-active-side pre {
background: var(--sn-stylekit-background-color);
color: var(--sn-stylekit-foreground-color);
border: 1px solid var(--sn-stylekit-border-color);
padding: 20px;
border-radius: 3px;
overflow-x: auto;
}
.editor-preview-active table, .editor-preview-active-side table {
display: block;
margin-bottom: 12px;
width: 100%;
overflow: auto;
border-collapse: collapse;
border-spacing: 0px;
border-color: var(--sn-stylekit-border-color);
}
.editor-preview-active table th, .editor-preview-active table td, .editor-preview-active-side table th, .editor-preview-active-side table td {
padding: 6px 13px;
border: 1px solid var(--sn-stylekit-border-color);
}
.editor-preview-active table tr:nth-child(2n), .editor-preview-active-side table tr:nth-child(2n) {
background-color: var(--sn-stylekit-background-color);
}
.editor-preview-active p code, .editor-preview-active-side p code {
padding: 3px 6px;
background-color: var(--sn-stylekit-background-color);
color: var(--sn-stylekit-info-color);
border: 1px solid var(--sn-stylekit-border-color);
border-radius: 3px;
}
.editor-preview-active code, .editor-preview-active-side code {
font-family: var(--sn-stylekit-monospace-font);
}
.editor-preview-active blockquote, .editor-preview-active-side blockquote {
padding: 0 0.5rem;
margin-left: 0;
color: var(--sn-stylekit-neutral-color);
border-left: 0.3rem solid var(--sn-stylekit-background-color);
}
.editor-preview-active blockquote > :first-child, .editor-preview-active-side blockquote > :first-child {
margin-top: 0;
}
.editor-preview-active blockquote > :last-child, .editor-preview-active-side blockquote > :last-child {
margin-bottom: 0;
}
.editor-preview-active {
border: 0;
}
.CodeMirror {
background-color: var(--sn-stylekit-editor-background-color) !important;
color: var(--sn-stylekit-editor-foreground-color) !important;
border: 0 !important;
}
.CodeMirror .CodeMirror-code .cm-comment {
background: var(--sn-stylekit-contrast-background-color);
color: var(--sn-stylekit-info-color);
font-family: Consolas, monaco, "Ubuntu Mono", courier, monospace !important;
font-size: 90%;
}
.CodeMirror .CodeMirror-code .cm-comment.CodeMirror-selectedtext {
color: var(--sn-stylekit-info-contrast-color) !important;
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .cm-header {
color: var(--sn-stylekit-editor-foreground-color);
}
.CodeMirror .cm-header.CodeMirror-selectedtext {
color: var(--sn-stylekit-info-contrast-color) !important;
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .cm-formatting-header, .CodeMirror .cm-formatting-strong, .CodeMirror .cm-formatting-em {
opacity: 0.2;
}
.CodeMirror .cm-link.cm-variable-2, .CodeMirror .cm-url.cm-variable-2 {
color: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .cm-link.cm-variable-2.CodeMirror-selectedtext, .CodeMirror .cm-url.cm-variable-2.CodeMirror-selectedtext {
color: var(--sn-stylekit-info-contrast-color) !important;
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .cm-formatting-list-ol {
font-weight: bold;
}
.CodeMirror .cm-link, .CodeMirror .cm-string {
color: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .cm-link.CodeMirror-selectedtext, .CodeMirror .cm-string.CodeMirror-selectedtext {
color: var(--sn-stylekit-info-contrast-color) !important;
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror .CodeMirror-linenumber {
color: gray !important;
}
.CodeMirror-cursor {
border-color: var(--sn-stylekit-editor-foreground-color);
}
.CodeMirror-selected {
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror-selectedtext {
color: var(--sn-stylekit-info-contrast-color);
background: var(--sn-stylekit-info-color) !important;
}
.CodeMirror-gutters {
background-color: var(--sn-stylekit-background-color) !important;
color: var(--sn-stylekit-editor-foreground-color) !important;
border-color: var(--sn-stylekit-border-color) !important;
}
@media only screen and (max-width: 700px) {
.editor-toolbar a.no-mobile {
display: inline-block;
}
}
/*
Highlight JS theming
*/
.hljs-comment,
.hljs-quote {
font-style: italic;
color: var(--sn-stylekit-neutral-color);
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
font-weight: bold;
}
.hljs-attribute {
color: var(--sn-stylekit-warning-color);
}
.hljs-number,
.hljs-literal {
color: var(--sn-stylekit-info-color);
}
.hljs-string,
.hljs-doctag,
.hljs-formula {
color: var(--sn-stylekit-success-color);
}
.hljs-title,
.hljs-section,
.hljs-selector-id {
font-weight: bold;
}
.hljs-subst {
font-weight: normal;
}
.hljs-class .hljs-title,
.hljs-type,
.hljs-name {
color: var(--sn-stylekit-danger-color);
font-weight: bold;
}
.hljs-tag {
color: var(--sn-stylekit-neutral-color);
}
.hljs-regexp {
color: var(--sn-stylekit-success-color);
}
.hljs-symbol,
.hljs-bullet,
.hljs-link {
color: var(--sn-stylekit-info-color);
}
.hljs-built_in,
.hljs-builtin-name {
text-decoration: underline;
}
.hljs-meta {
font-weight: bold;
}
.hljs-deletion {
color: var(--sn-stylekit-danger-color);
}
.hljs-addition {
color: var(--sn-stylekit-success-color);
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View File

@@ -0,0 +1,157 @@
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
document.addEventListener("DOMContentLoaded", function (event) {
var workingNote;
var componentManager = new ComponentManager(null, function () {
// on ready
document.body.classList.add(componentManager.platform);
document.body.classList.add(componentManager.environment);
});
var ignoreTextChange = false;
var initialLoad = true;
var lastValue, lastUUID, clientData;
componentManager.streamContextItem(function (note) {
if (note.uuid !== lastUUID) {
// Note changed, reset last values
lastValue = null;
initialLoad = true;
lastUUID = note.uuid;
clientData = note.clientData;
}
workingNote = note; // Only update UI on non-metadata updates.
if (note.isMetadataUpdate || !window.easymde) {
return;
}
if (note.content.text !== lastValue) {
ignoreTextChange = true;
window.easymde.value(note.content.text);
ignoreTextChange = false;
}
if (initialLoad) {
initialLoad = false;
window.easymde.codemirror.getDoc().clearHistory();
var mode = clientData && clientData.mode; // Set initial editor mode
if (mode === 'preview') {
if (!window.easymde.isPreviewActive()) {
window.easymde.togglePreview();
}
} else if (mode === 'split') {
if (!window.easymde.isSideBySideActive()) {
window.easymde.toggleSideBySide();
} // falback config
} else if (window.easymde.isPreviewActive()) {
window.easymde.togglePreview();
}
}
});
window.easymde = new EasyMDE({
element: document.getElementById("editor"),
autoDownloadFontAwesome: false,
spellChecker: false,
status: false,
shortcuts: {
toggleSideBySide: "Cmd-Alt-P"
},
// Syntax highlighting is disabled until we figure out performance issue: https://github.com/sn-extensions/advanced-markdown-editor/pull/20#issuecomment-513811633
// renderingConfig: {
// codeSyntaxHighlighting: true
// },
toolbar: [{
className: "fa fa-eye",
"default": true,
name: "preview",
noDisable: true,
title: "Toggle Preview",
action: function action() {
window.easymde.togglePreview();
saveMetadata();
}
}, {
className: "fa fa-columns",
"default": true,
name: "side-by-side",
noDisable: true,
noMobile: true,
title: "Toggle Side by Side",
action: function action() {
window.easymde.toggleSideBySide();
saveMetadata();
}
}, "|", "heading", "bold", "italic", "strikethrough", "|", "quote", "code", "|", "unordered-list", "ordered-list", "|", "clean-block", "|", "link", "image", "|", "table"]
});
function saveMetadata() {
function getEditorMode() {
var editor = window.easymde;
if (editor) {
if (editor.isPreviewActive()) return 'preview';
if (editor.isSideBySideActive()) return 'split';
}
return 'edit';
}
var note = workingNote;
componentManager.saveItemWithPresave(note, function () {
note.clientData = {
mode: getEditorMode()
};
});
} // Some sort of issue on Mobile RN where this causes an exception (".className is not defined")
try {
window.easymde.toggleFullScreen();
} catch (e) {}
/*
Can be set to Infinity to make sure the whole document is always rendered, and thus the browser's text search works on it. This will have bad effects on performance of big documents.
Really bad performance on Safari. Unusable.
*/
window.easymde.codemirror.setOption("viewportMargin", 100);
window.easymde.codemirror.on("change", function () {
function strip(html) {
var tmp = document.implementation.createHTMLDocument("New").body;
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
}
function truncateString(string) {
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 90;
if (string.length <= limit) {
return string;
} else {
return string.substring(0, limit) + "...";
}
}
if (!ignoreTextChange) {
if (workingNote) {
// Be sure to capture this object as a variable, as this.note may be reassigned in `streamContextItem`, so by the time
// you modify it in the presave block, it may not be the same object anymore, so the presave values will not be applied to
// the right object, and it will save incorrectly.
var note = workingNote;
componentManager.saveItemWithPresave(note, function () {
lastValue = window.easymde.value();
var html = window.easymde.options.previewRender(window.easymde.value());
var strippedHtml = truncateString(strip(html));
note.content.preview_plain = strippedHtml;
note.content.preview_html = null;
note.content.text = lastValue;
});
}
}
});
});
},{}]},{},[1]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

View File

@@ -0,0 +1 @@
<!doctype html><html><head><base target="_blank"><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1"><script src="lib/component-relay.js"></script><script src="vendor/highlightjs/highlightjs.js"></script><link rel="stylesheet" media="all" href="vendor/easymd/easymde.css"><script src="vendor/easymd/easymd.js"></script><link rel="stylesheet" media="all" href="stylekit.css"><title>Markdown Pro</title><script defer="defer" src="dist.js"></script><link href="dist.css" rel="stylesheet"></head><body class="sn-component" id="sn-advanced-markdown-editor"><textarea dir="auto" id="editor" hidden></textarea></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
/**
* easymde v2.16.1
* Copyright Jeroen Akkerman
* @link https://github.com/ionaru/easy-markdown-editor
* @license MIT
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
/*! highlight.js v9.16.2 | BSD3 License | git.io/hljslicense */

View File

@@ -0,0 +1,44 @@
{
"name": "sn-advanced-markdown-editor",
"version": "1.5.0",
"description": "A Standard Notes derived editor that offers full support for Markdown editing.",
"main": "dist/dist.js",
"author": "Standard Notes <hello@standardnotes.com>",
"license": "AGPL-3.0",
"sn": {
"main": "dist/index.html"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack serve --config webpack.dev.js --progress --hot",
"build": "webpack --config webpack.prod.js",
"lint": "eslint src --ext .js",
"lint:fix": "yarn lint --fix"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.13",
"@babel/preset-env": "^7.13.12",
"@standardnotes/component-relay": "2.2.0",
"@standardnotes/eslint-config-extensions": "^1.0.2",
"copy-webpack-plugin": "^8.1.0",
"css-loader": "^5.2.0",
"dompurify": "^2.2.9",
"easymde": "2.16.1",
"eslint": "^7.23.0",
"file-loader": "^6.2.0",
"font-awesome": "^4.7.0",
"highlightjs": "^9.16.2",
"html-webpack-plugin": "^5.3.1",
"marked": "^2.0.7",
"mini-css-extract-plugin": "^1.4.0",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"sn-stylekit": "3.0.1",
"webpack": "^5.28.0",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,67 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */
/**
* @license
* Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
* Build: `lodash include="includes,merge,filter,map,remove,find,omit,pull,cloneDeep,pick,uniq,sortedIndexBy,mergeWith"`
*/
/** @license React v0.19.1
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
/**
* @license
* Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
* Build: `lodash include="includes,merge,filter,map,remove,find,omit,pull,cloneDeep,pick,uniq,sortedIndexBy,mergeWith"`
*/

View File

@@ -0,0 +1 @@
<!doctype html><html><head><base target="_blank"><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1"><link href="vendor.css" rel="stylesheet"><script src="vendor.js"></script><script src="filesafe-js/EncryptionWorker.js"></script><title>Bold Editor</title><script defer="defer" src="dist.min.js"></script><link href="dist.css" rel="stylesheet"></head><body></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
{
"name": "sn-bold-editor",
"version": "1.3.5",
"main": "dist/dist.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint app/ --ext .js",
"lint:fix": "yarn lint --fix",
"build": "webpack --config webpack.prod.js",
"start": "webpack serve --config webpack.dev.js --progress --hot"
},
"sn": {
"main": "dist/index.html"
},
"devDependencies": {
"@babel/core": "^7.13.14",
"@babel/eslint-parser": "^7.13.14",
"@babel/preset-env": "^7.13.12",
"@babel/preset-react": "^7.13.13",
"@standardnotes/editor-kit": "2.2.3",
"@standardnotes/eslint-config-extensions": "^1.0.3",
"babel-loader": "^8.2.2",
"copy-webpack-plugin": "^8.1.1",
"css-loader": "^5.2.0",
"dompurify": "^2.2.9",
"eslint": "^7.23.0",
"eslint-plugin-react": "^7.23.1",
"filesafe-embed": "1.0.13",
"filesafe-js": "1.0.5",
"html-webpack-plugin": "^5.3.1",
"mini-css-extract-plugin": "^1.4.0",
"node-sass": "^5.0.0",
"react": "17.x",
"react-dom": "17.x",
"sass-loader": "^11.0.1",
"sn-stylekit": "3.0.1",
"style-loader": "~2.0.0",
"terser-webpack-plugin": "^5.1.1",
"webpack": "^5.30.0",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3",
"webpack-merge-and-include-globally": "^2.3.4"
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
body,html{font-family:sans-serif;height:100%;margin:0;font-size:var(--sn-stylekit-base-font-size)}.wrapper{display:flex;flex-direction:column;position:relative;height:100%;overflow-x:hidden}.CodeMirror{background-color:var(--sn-stylekit-editor-background-color) !important;color:var(--sn-stylekit-editor-foreground-color) !important;border:0 !important;font-family:var(--sn-stylekit-monospace-font);-webkit-overflow-scrolling:touch;font-size:calc(var(--sn-stylekit-font-size-editor) - 0.1rem);flex:1 1 auto;width:100%;height:100%;resize:none}.CodeMirror .cm-header{color:var(--sn-stylekit-editor-foreground-color)}.CodeMirror .cm-formatting-header,.CodeMirror .cm-formatting-strong,.CodeMirror .cm-formatting-em{opacity:.2}.CodeMirror .cm-variable,.CodeMirror .cm-variable-1,.CodeMirror .cm-variable-2,.CodeMirror .cm-variable-3,.CodeMirror .cm-string-2{color:var(--sn-stylekit-info-color) !important}.CodeMirror .cm-variable.CodeMirror-selectedtext,.CodeMirror .cm-variable-1.CodeMirror-selectedtext,.CodeMirror .cm-variable-2.CodeMirror-selectedtext,.CodeMirror .cm-variable-3.CodeMirror-selectedtext,.CodeMirror .cm-string-2.CodeMirror-selectedtext{color:var(--sn-stylekit-info-contrast-color) !important;background:transparent}.CodeMirror .cm-qualifier,.CodeMirror .cm-meta{color:var(--sn-stylekit-neutral-color) !important}.CodeMirror .cm-error{color:var(--sn-stylekit-danger-color) !important}.CodeMirror .cm-def,.CodeMirror .cm-atom{color:var(--sn-stylekit-success-color)}.CodeMirror .CodeMirror-linenumber{color:var(--sn-stylekit-neutral-color) !important;opacity:.5}.CodeMirror-cursor{border-color:var(--sn-stylekit-info-color) !important}.CodeMirror-cursors{z-index:10 !important}.CodeMirror-selected{background:var(--sn-stylekit-info-color) !important}.CodeMirror-gutters{background-color:var(--sn-stylekit-background-color) !important;color:var(--sn-stylekit-editor-foreground-color) !important;border-color:var(--sn-stylekit-border-color) !important}.cm-header-1{font-size:150%}.cm-header-2{font-size:130%}.cm-header-3{font-size:120%}.cm-header-4{font-size:110%}.cm-header-5{font-size:100%}.cm-header-6{font-size:90%}.CodeMirror .cm-quote{color:var(--sn-stylekit-foreground-color);opacity:.6}.cm-fat-cursor .CodeMirror-line>span[role=presentation]{caret-color:transparent}
/*# sourceMappingURL=main.css.map*/

View File

@@ -0,0 +1 @@
{"version":3,"sources":["webpack://sn-code-editor/./src/main.scss"],"names":[],"mappings":"AAAA,UACE,uBACA,YACA,SACA,4CAGF,SACE,aACA,sBACA,kBACA,YAGA,kBAGF,YACE,uEACA,4DACA,oBACA,8CACA,iCAGA,6DAEA,cACA,WACA,YACA,YAEA,uBACE,iDAIF,kGACE,WAGF,mIACE,+CAEA,2PACE,wDACA,uBAIJ,+CACE,kDAGF,sBACE,iDAOF,yCACE,uCAGF,mCACE,kDACA,WAIJ,mBACE,sDAGF,oBACE,sBAGF,qBACE,oDAGF,oBACE,gEACA,4DACA,wDAGF,4BACA,4BACA,4BACA,4BACA,4BACA,2BAEA,sBACE,0CACA,WAGF,wDACE,wB","file":"main.css","sourcesContent":["body, html {\n font-family: sans-serif;\n height: 100%;\n margin: 0;\n font-size: var(--sn-stylekit-base-font-size);\n}\n\n.wrapper {\n display: flex;\n flex-direction: column;\n position: relative;\n height: 100%;\n\n // Fixes unnecessary horizontal scrolling on Windows\n overflow-x: hidden;\n}\n\n.CodeMirror {\n background-color: var(--sn-stylekit-editor-background-color) !important;\n color: var(--sn-stylekit-editor-foreground-color) !important;\n border: 0 !important;\n font-family: var(--sn-stylekit-monospace-font);\n -webkit-overflow-scrolling: touch;\n\n // code doesn't look good at normal text size, better to be a bit smaller\n font-size: calc(var(--sn-stylekit-font-size-editor) - 0.1rem);\n\n flex: 1 1 auto;\n width: 100%;\n height: 100%;\n resize: none;\n\n .cm-header {\n color: var(--sn-stylekit-editor-foreground-color);\n }\n\n // Faded Markdown syntax\n .cm-formatting-header, .cm-formatting-strong, .cm-formatting-em {\n opacity: 0.2;\n }\n\n .cm-variable, .cm-variable-1, .cm-variable-2, .cm-variable-3, .cm-string-2 {\n color: var(--sn-stylekit-info-color) !important;\n\n &.CodeMirror-selectedtext {\n color: var(--sn-stylekit-info-contrast-color) !important;\n background: transparent;\n }\n }\n\n .cm-qualifier, .cm-meta {\n color: var(--sn-stylekit-neutral-color) !important;\n }\n\n .cm-error {\n color: var(--sn-stylekit-danger-color) !important;\n }\n\n .cm-property {\n\n }\n\n .cm-def, .cm-atom {\n color: var(--sn-stylekit-success-color);\n }\n\n .CodeMirror-linenumber {\n color: var(--sn-stylekit-neutral-color) !important;\n opacity: 0.5;\n }\n}\n\n.CodeMirror-cursor {\n border-color: var(--sn-stylekit-info-color) !important;\n}\n\n.CodeMirror-cursors {\n z-index: 10 !important; // In Markdown mode, cursor is hidden behind code blocks\n}\n\n.CodeMirror-selected {\n background: var(--sn-stylekit-info-color) !important;\n}\n\n.CodeMirror-gutters {\n background-color: var(--sn-stylekit-background-color) !important;\n color: var(--sn-stylekit-editor-foreground-color) !important;\n border-color: var(--sn-stylekit-border-color) !important;\n}\n\n.cm-header-1 { font-size: 150%; }\n.cm-header-2 { font-size: 130%; }\n.cm-header-3 { font-size: 120%; }\n.cm-header-4 { font-size: 110%; }\n.cm-header-5 { font-size: 100%; }\n.cm-header-6 { font-size: 90%; }\n\n.CodeMirror .cm-quote {\n color: var(--sn-stylekit-foreground-color);\n opacity: 0.6;\n}\n\n.cm-fat-cursor .CodeMirror-line > span[role=\"presentation\"] {\n caret-color: transparent;\n}\n"],"sourceRoot":""}

View File

@@ -0,0 +1,2 @@
document.addEventListener("DOMContentLoaded",(function(){const e=CodeMirror.modeInfo.reduce((function(e,t){return e[t.mode]?e[t.mode].push(t):e[t.mode]=[t],e}),{}),t=CodeMirror.modeInfo.reduce((function(e,t){return e[t.name]={mode:t.mode,mime:t.mime},e}),{}),n=Object.keys(t);let o,i,a,d,m,c,r,s=!1,l=!0;function u(){if(i){let e=i;o.saveItemWithPresave(e,(()=>{d=c.getValue(),e.content.text=d,e.clientData=a,e.content.preview_plain=null,e.content.preview_html=null}))}}function f(o){if(!o)return;const i=function(n){const o=function(e){return e?{name:e.name,mode:e.mode,mime:e.mime}:null},i=/.+\.([^.]+)$/.exec(n),a=/\//.test(n);if(i)return o(CodeMirror.findModeByExtension(i[1]));if(a)return o(CodeMirror.findModeByMIME(a[1]));if(t[n])return{name:n,mode:t[n].mode,mime:t[n].mime};if(e[n]){const t=e[n][0];return{name:t.name,mode:t.mode,mime:t.mime}}return{name:n,mode:n,mime:n}}(o);i?(c.setOption("mode",i.mime),CodeMirror.autoLoadMode(c,i.mode),a&&(a.mode=i.name),document.getElementById("language-select").selectedIndex=n.indexOf(i.name)):console.error("Could not find a mode corresponding to "+o)}window.setKeyMap=function(e){c.setOption("keyMap",e),function(e){const t=document.getElementById("toggle-vim-mode-button"),n="vim"===e?"Disable":"Enable",o="vim"===e?"danger":"success";t.innerHTML=`${n} Vim mode`,t.classList.remove("danger"),t.classList.remove("success"),t.classList.add(o)}(e)},window.onLanguageSelect=function(){f(n[r.selectedIndex]),u()},window.setDefaultLanguage=function(){const e=n[r.selectedIndex];o.setComponentDataValueForKey("language",e);const t=document.getElementById("default-label"),i=t.innerHTML;t.innerHTML="Success",t.classList.add("success"),setTimeout((function(){t.classList.remove("success"),t.innerHTML=i}),750)},window.toggleVimMode=function(){let e;e="default"===(o.getComponentDataValueForKey("keyMap")??"default")?"vim":"default",window.setKeyMap(e),o.setComponentDataValueForKey("keyMap",e)},o=new ComponentRelay({targetWindow:window,onReady:()=>{const e=o.platform;e&&document.body.classList.add(e),function(){CodeMirror.commands.save=function(){u()},c=CodeMirror.fromTextArea(document.getElementById("code"),{extraKeys:{"Alt-F":"findPersistent"},lineNumbers:!0,styleSelectedText:!0,lineWrapping:!0,inputStyle:"mobile"===(o.environment??"web")?"textarea":"contenteditable"}),c.setSize("100%","100%"),function(){r=document.getElementById("language-select");for(let e=0;e<n.length;e++){const t=document.createElement("option");t.value=e,t.innerHTML=n[e],r.appendChild(t)}}(),c.on("change",(function(){s||u()}));c.on("cursorActivity",(function(e){"mobile"===o.environment&&(e=>{setTimeout((()=>e.scrollIntoView()),200)})(e)}));const e=o.getComponentDataValueForKey("keyMap")??"default";window.setKeyMap(e)}()}}),o.streamContextItem((e=>{!function(e){if(e.uuid!==m&&(d=null,l=!0,m=e.uuid),i=e,e.isMetadataUpdate)return;a=e.clientData;let t=a.mode;t||(t=o.getComponentDataValueForKey("language")??"JavaScript"),f(t),c&&(e.content.text!==d&&(s=!0,c.getDoc().setValue(i.content.text),s=!1),l&&(l=!1,c.getDoc().clearHistory()),c.setOption("spellcheck",i.content.spellcheck))}(e)}))}));
//# sourceMappingURL=main.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<base target="_blank">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<link rel="stylesheet" href="vendor/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="dist/main.css">
<link rel="stylesheet" href="dist/stylekit.css">
<script src="vendor/codemirror/lib/codemirror.js"></script>
<!-- Required for gfm mode -->
<script src="vendor/codemirror/addon/mode/overlay.js"></script>
<script src="vendor/codemirror/addon/mode/simple.js"></script>
<script src="vendor/codemirror/addon/mode/loadmode.js"></script>
<script src="vendor/codemirror/mode/meta.js"></script>
<!-- Vim key bindings -->
<script src="vendor/codemirror/keymap/vim.js"></script>
<!-- Required for search -->
<script src="vendor/codemirror/addon/search/jump-to-line.js"></script>
<script src="vendor/codemirror/addon/search/match-highlighter.js"></script>
<script src="vendor/codemirror/addon/search/matchesonscrollbar.js"></script>
<script src="vendor/codemirror/addon/search/search.js"></script>
<script src="vendor/codemirror/addon/search/searchcursor.js"></script>
<script src="vendor/codemirror/addon/dialog/dialog.js"></script>
<script src="vendor/codemirror/addon/scroll/annotatescrollbar.js"></script>
<link rel="stylesheet" href="vendor/codemirror/addon/search/matchesonscrollbar.css" />
<link rel="stylesheet" href="vendor/codemirror/addon/dialog/dialog.css" />
<script src="dist/lib/component-relay.js"></script>
<!-- Required for styling selected text -->
<script src="vendor/codemirror/addon/selection/mark-selection.js"></script>
<script>
CodeMirror.modeURL = "vendor/codemirror/mode/%N/%N.js";
</script>
</head>
<body class="sn-component">
<div class="wrapper">
<textarea id="code" name="code"></textarea>
<div>
<div class="sk-app-bar no-edges no-bottom-edge" style="width: inherit;">
<div class="left">
<div class="sk-app-bar-item no-pointer">
<span class="sk-p">Language:</span>
</div>
<div class="sk-app-bar-item no-pointer">
<select id="language-select" onchange="onLanguageSelect(event)"></select>
</div>
<div class="sk-app-bar-item">
<span id="default-label" class="sk-label" onclick="setDefaultLanguage(event)">Set as Default</span>
</div>
</div>
<div class="center"></div>
<div class="right">
<div class="sk-app-bar-item no-pointer border"></div>
<div class="sk-app-bar-item">
<span id="toggle-vim-mode-button" class="sk-label" onclick="toggleVimMode()">Enable Vim mode</span>
</div>
</div>
</div>
<script src="dist/main.js"></script>
</body>
</html>

View File

@@ -0,0 +1,34 @@
{
"name": "sn-code-editor",
"version": "1.3.12",
"description": "A code editor for Standard Notes",
"main": "dist/main.js",
"author": "Standard Notes <hello@standardnotes.org>",
"license": "AGPL-3.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "http-server . --cors -p8001 & webpack --progress --config webpack.dev.js",
"build": "webpack --config webpack.prod.js",
"lint": "eslint src --ext .js",
"lint:fix": "yarn lint --fix"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@standardnotes/component-relay": "2.2.0",
"codemirror": "5.65.2",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.0.1",
"eslint": "^7.18.0",
"http-server": "^0.12.3",
"mini-css-extract-plugin": "^1.3.5",
"remove-files-webpack-plugin": "^1.4.4",
"sass": "^1.32.5",
"sass-loader": "^10.1.1",
"sn-stylekit": "^2.1.1",
"webpack": "^5.19.0",
"webpack-cli": "^4.4.0",
"webpack-merge": "^5.7.3"
}
}

View File

@@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){"use strict";var n={},t=/[^\s\u00a0]/,i=e.Pos,l=e.cmpPos;function o(e){var n=e.search(t);return-1==n?0:n}function r(e,n){var t=e.getMode();return!1!==t.useInnerComments&&t.innerMode?e.getModeAt(n):t}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",(function(e){e||(e=n);for(var t=this,l=1/0,o=this.listSelections(),r=null,a=o.length-1;a>=0;a--){var m=o[a].from(),c=o[a].to();m.line>=l||(c.line>=l&&(c=i(l,0)),l=m.line,null==r?t.uncomment(m,c,e)?r="un":(t.lineComment(m,c,e),r="line"):"un"==r?t.uncomment(m,c,e):t.lineComment(m,c,e))}})),e.defineExtension("lineComment",(function(e,l,a){a||(a=n);var m=this,c=r(m,e),g=m.getLine(e.line);if(null!=g&&(f=e,s=g,!/\bstring\b/.test(m.getTokenTypeAt(i(f.line,0)))||/^[\'\"\`]/.test(s))){var f,s,d=a.lineComment||c.lineComment;if(d){var u=Math.min(0!=l.ch||l.line==e.line?l.line+1:l.line,m.lastLine()+1),h=null==a.padding?" ":a.padding,C=a.commentBlankLines||e.line==l.line;m.operation((function(){if(a.indent){for(var n=null,l=e.line;l<u;++l){var r=(c=m.getLine(l)).slice(0,o(c));(null==n||n.length>r.length)&&(n=r)}for(l=e.line;l<u;++l){var c=m.getLine(l),g=n.length;(C||t.test(c))&&(c.slice(0,g)!=n&&(g=o(c)),m.replaceRange(n+d+h,i(l,0),i(l,g)))}}else for(l=e.line;l<u;++l)(C||t.test(m.getLine(l)))&&m.replaceRange(d+h,i(l,0))}))}else(a.blockCommentStart||c.blockCommentStart)&&(a.fullLines=!0,m.blockComment(e,l,a))}})),e.defineExtension("blockComment",(function(e,o,a){a||(a=n);var m=this,c=r(m,e),g=a.blockCommentStart||c.blockCommentStart,f=a.blockCommentEnd||c.blockCommentEnd;if(g&&f){if(!/\bcomment\b/.test(m.getTokenTypeAt(i(e.line,0)))){var s=Math.min(o.line,m.lastLine());s!=e.line&&0==o.ch&&t.test(m.getLine(s))&&--s;var d=null==a.padding?" ":a.padding;e.line>s||m.operation((function(){if(0!=a.fullLines){var n=t.test(m.getLine(s));m.replaceRange(d+f,i(s)),m.replaceRange(g+d,i(e.line,0));var r=a.blockCommentLead||c.blockCommentLead;if(null!=r)for(var u=e.line+1;u<=s;++u)(u!=s||n)&&m.replaceRange(r+d,i(u,0))}else{var h=0==l(m.getCursor("to"),o),C=!m.somethingSelected();m.replaceRange(f,o),h&&m.setSelection(C?o:m.getCursor("from"),o),m.replaceRange(g,e)}}))}}else(a.lineComment||c.lineComment)&&0!=a.fullLines&&m.lineComment(e,o,a)})),e.defineExtension("uncomment",(function(e,l,o){o||(o=n);var a,m=this,c=r(m,e),g=Math.min(0!=l.ch||l.line==e.line?l.line:l.line-1,m.lastLine()),f=Math.min(e.line,g),s=o.lineComment||c.lineComment,d=[],u=null==o.padding?" ":o.padding;e:if(s){for(var h=f;h<=g;++h){var C=m.getLine(h),p=C.indexOf(s);if(p>-1&&!/comment/.test(m.getTokenTypeAt(i(h,p+1)))&&(p=-1),-1==p&&t.test(C))break e;if(p>-1&&t.test(C.slice(0,p)))break e;d.push(C)}if(m.operation((function(){for(var e=f;e<=g;++e){var n=d[e-f],t=n.indexOf(s),l=t+s.length;t<0||(n.slice(l,l+u.length)==u&&(l+=u.length),a=!0,m.replaceRange("",i(e,t),i(e,l)))}})),a)return!0}var v=o.blockCommentStart||c.blockCommentStart,b=o.blockCommentEnd||c.blockCommentEnd;if(!v||!b)return!1;var k=o.blockCommentLead||c.blockCommentLead,L=m.getLine(f),x=L.indexOf(v);if(-1==x)return!1;var R=g==f?L:m.getLine(g),O=R.indexOf(b,g==f?x+v.length:0),T=i(f,x+1),S=i(g,O+1);if(-1==O||!/comment/.test(m.getTokenTypeAt(T))||!/comment/.test(m.getTokenTypeAt(S))||m.getRange(T,S,"\n").indexOf(b)>-1)return!1;var y=L.lastIndexOf(v,e.ch),E=-1==y?-1:L.slice(0,e.ch).indexOf(b,y+v.length);if(-1!=y&&-1!=E&&E+b.length!=e.ch)return!1;E=R.indexOf(b,l.ch);var M=R.slice(l.ch).lastIndexOf(v,E-l.ch);return y=-1==E||-1==M?-1:l.ch+M,(-1==E||-1==y||y==l.ch)&&(m.operation((function(){m.replaceRange("",i(g,O-(u&&R.slice(O-u.length,O)==u?u.length:0)),i(g,O+b.length));var e=x+v.length;if(u&&L.slice(e,e+u.length)==u&&(e+=u.length),m.replaceRange("",i(f,x),i(f,e)),k)for(var n=f+1;n<=g;++n){var l=m.getLine(n),o=l.indexOf(k);if(-1!=o&&!t.test(l.slice(0,o))){var r=o+k.length;u&&l.slice(r,r+u.length)==u&&(r+=u.length),m.replaceRange("",i(n,o),i(n,r))}}})),!0)}))}));

View File

@@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){var n=/\S/g,t=String.prototype.repeat||function(e){return Array(e+1).join(this)};function o(n){if(n.getOption("disableInput"))return e.Pass;for(var o,r=n.listSelections(),c=[],f=0;f<r.length;f++){var a=r[f].head;if(!/\bcomment\b/.test(n.getTokenTypeAt(a)))return e.Pass;var m=n.getModeAt(a);if(o){if(o!=m)return e.Pass}else o=m;var s,u,d=null,p=o.blockCommentStart,h=o.lineComment;if(p&&o.blockCommentContinue){var b=(s=n.getLine(a.line)).lastIndexOf(o.blockCommentEnd,a.ch-o.blockCommentEnd.length);if(-1!=b&&b==a.ch-o.blockCommentEnd.length||h&&(u=s.lastIndexOf(h,a.ch-1))>-1&&/\bcomment\b/.test(n.getTokenTypeAt({line:a.line,ch:u+1})));else if(a.ch>=p.length&&(u=s.lastIndexOf(p,a.ch-p.length))>-1&&u>b)if(i(0,s)>=u)d=s.slice(0,u);else{var g,C=n.options.tabSize;u=e.countColumn(s,u,C),d=n.options.indentWithTabs?t.call("\t",g=Math.floor(u/C))+t.call(" ",u-C*g):t.call(" ",u)}else(u=s.indexOf(o.blockCommentContinue))>-1&&u<=a.ch&&u<=i(0,s)&&(d=s.slice(0,u));null!=d&&(d+=o.blockCommentContinue)}if(null==d&&h&&l(n))if(null==s&&(s=n.getLine(a.line)),u=s.indexOf(h),a.ch||u){if(u>-1&&i(0,s)>=u){if(!(d=i(a.ch,s)>-1)){var v=n.getLine(a.line+1)||"",y=v.indexOf(h);d=y>-1&&i(0,v)>=y||null}d&&(d=s.slice(0,u)+h+s.slice(u+h.length).match(/^\s*/)[0])}}else d="";if(null==d)return e.Pass;c[f]="\n"+d}n.operation((function(){for(var e=r.length-1;e>=0;e--)n.replaceRange(c[e],r[e].from(),r[e].to(),"+insert")}))}function i(e,t){n.lastIndex=e;var o=n.exec(t);return o?o.index:-1}function l(e){var n=e.getOption("continueComments");return!n||"object"!=typeof n||!1!==n.continueLineComment}e.defineOption("continueComments",null,(function(n,t,i){if(i&&i!=e.Init&&n.removeKeyMap("continueComment"),t){var l="Enter";"string"==typeof t?l=t:"object"==typeof t&&t.key&&(l=t.key);var r={name:"continueComment"};r[l]=o,n.addKeyMap(r)}}))}));

View File

@@ -0,0 +1,32 @@
.CodeMirror-dialog {
position: absolute;
left: 0; right: 0;
background: inherit;
z-index: 15;
padding: .1em .8em;
overflow: hidden;
color: inherit;
}
.CodeMirror-dialog-top {
border-bottom: 1px solid #eee;
top: 0;
}
.CodeMirror-dialog-bottom {
border-top: 1px solid #eee;
bottom: 0;
}
.CodeMirror-dialog input {
border: none;
outline: none;
background: transparent;
width: 20em;
color: inherit;
font-family: monospace;
}
.CodeMirror-dialog button {
font-size: 70%;
}

Some files were not shown because too many files have changed in this diff Show More