codeserver 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Procfile +3 -0
- data/README.md +32 -0
- data/Rakefile +18 -0
- data/bin/setup +7 -0
- data/codeserver.gemspec +30 -0
- data/exe/codeserver +29 -0
- data/lib/.babelrc +4 -0
- data/lib/codeserver.rb +79 -0
- data/lib/codeserver/version.rb +3 -0
- data/lib/file_extensions.rb +20 -0
- data/lib/package.json +29 -0
- data/lib/public/assets/app.jsx +244 -0
- data/lib/public/assets/copy.png +0 -0
- data/lib/public/assets/editor.css +232 -0
- data/lib/public/assets/solarized-dark.css +84 -0
- data/lib/public/assets/style.css +58 -0
- data/lib/public/assets/tree.css +88 -0
- data/lib/tree.rb +47 -0
- data/lib/views/index.html.erb +17 -0
- data/lib/webpack.config.js +13 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3fc7a72117e1fc7fdbdd887c145e95642b74dcf5
|
4
|
+
data.tar.gz: 6abe538504cac145d630d13b28345ce72f91a47d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64fbb8d1bd73f1cbf1b85e43abdc4e8fe6044a7a7a2365f48d27363b01eadcfb03ba4441839a04eca40ef4e62ccbf3327ae59b0c87919b77f41f3e6170bceb07
|
7
|
+
data.tar.gz: 556f2664dbb33415565a2a574ae32e825edf674d9e5211b490e3499f66cff066298225b37d6f03fc7c842f1cb3e7166a41aa8faa241a174954768f181c1b7672
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Gavin Stark
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Procfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# CodeServer
|
2
|
+
|
3
|
+
This gem adds a `codeserver` command which, when supplied a parameter of a directory, will server this directory as a browsable code repository.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install this gem:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem install codeserver
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ codeserver --directory . --port 4242 --binding 0.0.0.0
|
16
|
+
|
17
|
+
The options above show the defaults.
|
18
|
+
|
19
|
+
## Development
|
20
|
+
|
21
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
22
|
+
|
23
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/code-server. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
28
|
+
|
29
|
+
|
30
|
+
## License
|
31
|
+
|
32
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'codeserver'
|
3
|
+
require 'sinatra'
|
4
|
+
|
5
|
+
file 'lib/public/dist/bundle.js' => FileList['lib/public/assets/**'] do
|
6
|
+
puts "Webpack"
|
7
|
+
%x{cd lib; webpack}
|
8
|
+
end
|
9
|
+
|
10
|
+
task :build => 'lib/public/dist/bundle.js'
|
11
|
+
|
12
|
+
desc "devserver"
|
13
|
+
task :devserver do
|
14
|
+
CodeServer::SinatraApp.setup!
|
15
|
+
|
16
|
+
CodeServer::SinatraApp.run!(root_path: File.expand_path("."))
|
17
|
+
end
|
18
|
+
|
data/bin/setup
ADDED
data/codeserver.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'codeserver/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codeserver"
|
8
|
+
spec.version = CodeServer::VERSION
|
9
|
+
spec.authors = ["Gavin Stark"]
|
10
|
+
spec.email = ["gavin@gstark.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Serves your local directory of code with a navigatable project tree and code formatting}
|
13
|
+
spec.description = %q{Serves your local directory of code with a navigatable project tree and code formatting}
|
14
|
+
spec.homepage = "https://github.com/gstark/code-server"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.files += ["lib/public/dist/bundle.js"]
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "awesome_print"
|
26
|
+
|
27
|
+
spec.add_dependency "sinatra"
|
28
|
+
spec.add_dependency "sinatra-websocket"
|
29
|
+
spec.add_dependency "rb-fsevent"
|
30
|
+
end
|
data/exe/codeserver
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'codeserver'
|
4
|
+
require 'sinatra'
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = CodeServer::SinatraApp::DEFAULT_OPTIONS
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: code-server [options]"
|
12
|
+
|
13
|
+
opts.on("-d", "--directory DIRECTORY", "Directory to serve (defaults to .)") do |directory|
|
14
|
+
options[:directory] = directory
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-b", "--binding BINDING", "Binds to the specified IP (defaults to 0.0.0.0)") do |binding|
|
18
|
+
options[:binding] = binding
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-p", "--port PORT", "Port number to use (defaults to 4242)") do |port|
|
22
|
+
options[:port] = port
|
23
|
+
end
|
24
|
+
end.parse!
|
25
|
+
|
26
|
+
CodeServer::SinatraApp.setup!(options)
|
27
|
+
|
28
|
+
CodeServer::SinatraApp.run!(root_path: File.expand_path(options[:directory]))
|
29
|
+
|
data/lib/.babelrc
ADDED
data/lib/codeserver.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "codeserver/version"
|
2
|
+
require 'sinatra'
|
3
|
+
require 'sinatra-websocket'
|
4
|
+
require 'rb-fsevent'
|
5
|
+
require 'awesome_print' if development?
|
6
|
+
|
7
|
+
require 'find'
|
8
|
+
require 'erb'
|
9
|
+
require 'json'
|
10
|
+
require 'date'
|
11
|
+
require 'open3'
|
12
|
+
|
13
|
+
require_relative 'file_extensions'
|
14
|
+
require_relative 'tree'
|
15
|
+
|
16
|
+
module CodeServer
|
17
|
+
class SinatraApp < Sinatra::Base
|
18
|
+
DEFAULT_OPTIONS = { directory: ".", binding: "0.0.0.0", port: 4242 }
|
19
|
+
|
20
|
+
def self.setup!(options = DEFAULT_OPTIONS)
|
21
|
+
Sinatra::Base.set(:port, options[:port])
|
22
|
+
Sinatra::Base.set(:bind, options[:binding])
|
23
|
+
Sinatra::Base.set(:show_exceptions, false)
|
24
|
+
end
|
25
|
+
|
26
|
+
set :public_folder, File.expand_path(File.join(File.dirname(__FILE__), "public"))
|
27
|
+
|
28
|
+
Tilt.register Tilt::ERBTemplate, 'html.erb'
|
29
|
+
|
30
|
+
get '/' do
|
31
|
+
erb :index
|
32
|
+
end
|
33
|
+
|
34
|
+
get '/file' do
|
35
|
+
@path = params[:path]
|
36
|
+
|
37
|
+
erb :index
|
38
|
+
end
|
39
|
+
|
40
|
+
get '/directory.json' do
|
41
|
+
tree = Tree.new(settings.root_path)
|
42
|
+
|
43
|
+
content_type :json
|
44
|
+
|
45
|
+
tree.directory_structure.to_json
|
46
|
+
end
|
47
|
+
|
48
|
+
get '/code' do
|
49
|
+
send_file File.safe_join(settings.root_path, params[:file]).tr(";", "")
|
50
|
+
end
|
51
|
+
|
52
|
+
get '/updates' do
|
53
|
+
tree = Tree.new(settings.root_path)
|
54
|
+
fsevent = FSEvent.new
|
55
|
+
|
56
|
+
request.websocket do |websocket|
|
57
|
+
websocket.onopen do
|
58
|
+
fsevent.watch(settings.root_path) do |change|
|
59
|
+
websocket.send(({ tree: tree.directory_structure }.to_json))
|
60
|
+
end
|
61
|
+
|
62
|
+
fsevent.watch(settings.root_path, file_events: true) do |changes|
|
63
|
+
changes.select { |change| File.file?(change) }.each do |change|
|
64
|
+
content = File.read(change)
|
65
|
+
path = change.gsub(settings.root_path) { "." }
|
66
|
+
websocket.send(({ content: content, path: path }.to_json))
|
67
|
+
end
|
68
|
+
websocket.send(({ tree: tree.directory_structure }.to_json))
|
69
|
+
end
|
70
|
+
fsevent.run
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
error do
|
76
|
+
"ooops"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
class File
|
4
|
+
TraversalException = Class.new(StandardError)
|
5
|
+
|
6
|
+
# Returns a String containing the path to the specified file with the
|
7
|
+
# guarantee that the resulting file path is a subdirectory of the source
|
8
|
+
# path. This avoids tricks like specifiying "../../../../../../etc/passwd"
|
9
|
+
# in the filename part
|
10
|
+
def self.safe_join(root_path, *segments)
|
11
|
+
clean_path = Pathname(root_path).cleanpath
|
12
|
+
|
13
|
+
new_path = clean_path
|
14
|
+
Array(segments).each { |segment| new_path += segment.to_s }
|
15
|
+
|
16
|
+
new_path.ascend { |path| return new_path.to_s if (path == clean_path) }
|
17
|
+
|
18
|
+
raise TraversalException
|
19
|
+
end
|
20
|
+
end
|
data/lib/package.json
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"name": "codeserver",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "Local Code Server",
|
5
|
+
"readme": "../README.md",
|
6
|
+
"main": "app.jsx",
|
7
|
+
"scripts": {
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
9
|
+
},
|
10
|
+
"author": "Gavin Stark",
|
11
|
+
"license": "MIT",
|
12
|
+
"dependencies": {
|
13
|
+
"react": "^0.14.8",
|
14
|
+
"react-copy-to-clipboard": "^4.2.2",
|
15
|
+
"react-dom": "^0.14.1",
|
16
|
+
"react-highlight": "0.8.0",
|
17
|
+
"redux": "^3.0.4"
|
18
|
+
},
|
19
|
+
"repository": {
|
20
|
+
"type": "git",
|
21
|
+
"url": ""
|
22
|
+
},
|
23
|
+
"devDependencies": {
|
24
|
+
"babel-core": "^5.8.33",
|
25
|
+
"babel-loader": "^5.3.3",
|
26
|
+
"babel-plugin-react-transform": "^1.1.1",
|
27
|
+
"webpack": "^1.12.2"
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,244 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
import React from 'react';
|
4
|
+
import ReactDOM from 'react-dom';
|
5
|
+
import * as Redux from 'redux';
|
6
|
+
import ReactHighlight from 'react-highlight';
|
7
|
+
import CopyToClipboard from 'react-copy-to-clipboard';
|
8
|
+
|
9
|
+
function transformer(state, action)
|
10
|
+
{
|
11
|
+
switch(action.type)
|
12
|
+
{
|
13
|
+
case 'LOADING_TREE': return { ...state, isLoadingFile: false, isLoadingTree: true }
|
14
|
+
case 'LOADED_TREE': return { ...state, isLoadingFile: false, isLoadingTree: false, tree: action.tree }
|
15
|
+
case 'LOADING_FILE': return { ...state, isLoadingFile: true, contents: "", selected_path: action.path }
|
16
|
+
case 'LOADED_FILE': return { ...state, isLoadingFile: false, contents: action.contents }
|
17
|
+
}
|
18
|
+
|
19
|
+
return {}
|
20
|
+
}
|
21
|
+
|
22
|
+
let store = Redux.createStore(transformer)
|
23
|
+
store.dispatch({type: 'LOADED_TREE', tree: { directories: [], files: [] } })
|
24
|
+
|
25
|
+
store.subscribe(() => {
|
26
|
+
let state = store.getState()
|
27
|
+
|
28
|
+
if (state.isLoadingFile)
|
29
|
+
{
|
30
|
+
fetch(`/code?file=${state.selected_path}`).
|
31
|
+
then(response => response.text()).
|
32
|
+
then(data => { store.dispatch({type: 'LOADED_FILE', contents: data }) })
|
33
|
+
}
|
34
|
+
})
|
35
|
+
|
36
|
+
store.subscribe(() => {
|
37
|
+
let state = store.getState()
|
38
|
+
|
39
|
+
if (state.isLoadingTree)
|
40
|
+
{
|
41
|
+
fetch('/directory.json').then(response => response.json()).
|
42
|
+
then(data => { store.dispatch({type: 'LOADED_TREE', tree: data }) })
|
43
|
+
}
|
44
|
+
})
|
45
|
+
|
46
|
+
class File extends React.Component
|
47
|
+
{
|
48
|
+
handleClick(path)
|
49
|
+
{
|
50
|
+
store.dispatch({type: 'LOADING_FILE', path})
|
51
|
+
window.history.pushState(null, null, "/file?path=" + path);
|
52
|
+
}
|
53
|
+
|
54
|
+
render()
|
55
|
+
{
|
56
|
+
return (
|
57
|
+
<li onClick={this.handleClick.bind(this, this.props.path)} className={`file ${this.props.path == store.getState().selected_path ? 'active' : ''}`}>
|
58
|
+
<a>{this.props.name}</a>
|
59
|
+
</li>
|
60
|
+
)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
class Directory extends React.Component
|
65
|
+
{
|
66
|
+
render()
|
67
|
+
{
|
68
|
+
let state = store.getState();
|
69
|
+
let checked = (state.selected_path && state.selected_path.startsWith(this.props.path)) ? "checked" : "";
|
70
|
+
|
71
|
+
return (
|
72
|
+
<li>
|
73
|
+
<label>{this.props.name}</label>
|
74
|
+
<input type="checkbox" defaultChecked={checked}/>
|
75
|
+
<SubDirectory directories={this.props.directories} files={this.props.files}/>
|
76
|
+
</li>
|
77
|
+
)
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
class SubDirectory extends React.Component
|
82
|
+
{
|
83
|
+
get directories()
|
84
|
+
{
|
85
|
+
return this.props.directories.map(
|
86
|
+
(directory) => <Directory key={directory.path}
|
87
|
+
path={directory.path}
|
88
|
+
name={directory.name}
|
89
|
+
directories={directory.directories}
|
90
|
+
files={directory.files}/>
|
91
|
+
)
|
92
|
+
}
|
93
|
+
|
94
|
+
get files()
|
95
|
+
{
|
96
|
+
return this.props.files.map(
|
97
|
+
(file) => <File name={file.name} key={file.path} path={file.path}/>
|
98
|
+
)
|
99
|
+
}
|
100
|
+
|
101
|
+
render()
|
102
|
+
{
|
103
|
+
return (
|
104
|
+
<ol>
|
105
|
+
{this.directories}
|
106
|
+
{this.files}
|
107
|
+
</ol>
|
108
|
+
)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
class Tree extends React.Component
|
113
|
+
{
|
114
|
+
constructor(props) {
|
115
|
+
super(props)
|
116
|
+
this.state = store.getState()
|
117
|
+
}
|
118
|
+
|
119
|
+
componentDidMount()
|
120
|
+
{
|
121
|
+
store.subscribe(() => { this.setState(store.getState()) })
|
122
|
+
}
|
123
|
+
|
124
|
+
render()
|
125
|
+
{
|
126
|
+
return (
|
127
|
+
<div id="tree">
|
128
|
+
<SubDirectory directories={this.state.tree.directories} files={this.state.tree.files}/>
|
129
|
+
</div>
|
130
|
+
)
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
class CurrentlyViewingPath extends React.Component
|
135
|
+
{
|
136
|
+
constructor(props)
|
137
|
+
{
|
138
|
+
super(props)
|
139
|
+
this.state = store.getState()
|
140
|
+
}
|
141
|
+
|
142
|
+
componentDidMount()
|
143
|
+
{
|
144
|
+
store.subscribe(() => { this.setState(store.getState()) })
|
145
|
+
}
|
146
|
+
|
147
|
+
render()
|
148
|
+
{
|
149
|
+
return (
|
150
|
+
<h1 id="currently-viewing-path">
|
151
|
+
{this.state.selected_path}
|
152
|
+
</h1>
|
153
|
+
)
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
class FileViewer extends React.Component
|
158
|
+
{
|
159
|
+
constructor(props)
|
160
|
+
{
|
161
|
+
super(props)
|
162
|
+
this.state = store.getState()
|
163
|
+
}
|
164
|
+
|
165
|
+
componentDidMount()
|
166
|
+
{
|
167
|
+
store.subscribe(() => { this.setState(store.getState()) })
|
168
|
+
}
|
169
|
+
|
170
|
+
render()
|
171
|
+
{
|
172
|
+
let extension = /(?:\.([^.]+))?$/.exec(this.state.selected_path)[1];
|
173
|
+
|
174
|
+
return (
|
175
|
+
<div>
|
176
|
+
<CopyToClipboard text={this.state.contents}>
|
177
|
+
<a className="copy">Copy to clipboard</a>
|
178
|
+
</CopyToClipboard>
|
179
|
+
<ReactHighlight className={extension}>
|
180
|
+
{this.state.contents}
|
181
|
+
</ReactHighlight>
|
182
|
+
</div>
|
183
|
+
)
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
class App extends React.Component
|
188
|
+
{
|
189
|
+
constructor()
|
190
|
+
{
|
191
|
+
super();
|
192
|
+
|
193
|
+
this.ws = new WebSocket('ws://' + window.location.host + '/updates');
|
194
|
+
|
195
|
+
this.ws.onmessage = (message) => {
|
196
|
+
let state = store.getState();
|
197
|
+
let data = JSON.parse(message.data)
|
198
|
+
if (data.tree)
|
199
|
+
{
|
200
|
+
store.dispatch({ type: 'LOADED_TREE', tree: data.tree });
|
201
|
+
}
|
202
|
+
if (data.content && (data.path === state.selected_path))
|
203
|
+
{
|
204
|
+
store.dispatch({ type: 'LOADED_FILE', contents: data.content });
|
205
|
+
}
|
206
|
+
};
|
207
|
+
}
|
208
|
+
|
209
|
+
componentDidMount()
|
210
|
+
{
|
211
|
+
store.subscribe(() => { this.setState(store.getState()) })
|
212
|
+
}
|
213
|
+
|
214
|
+
render()
|
215
|
+
{
|
216
|
+
return (
|
217
|
+
<div id="app">
|
218
|
+
<div id="sidebar">
|
219
|
+
<Tree key='app'/>
|
220
|
+
</div>
|
221
|
+
<div id="main">
|
222
|
+
<CurrentlyViewingPath key='currently-viewing-path'/>
|
223
|
+
<FileViewer key='fileviewer'/>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
)
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
ReactDOM.render(
|
231
|
+
<App/>,
|
232
|
+
document.getElementById('root')
|
233
|
+
)
|
234
|
+
|
235
|
+
store.dispatch({type: 'LOADING_TREE'})
|
236
|
+
let defaultPath = document.getElementById("root").getAttribute("data-path");
|
237
|
+
if (defaultPath)
|
238
|
+
{
|
239
|
+
store.dispatch({type: 'LOADING_FILE', path: defaultPath});
|
240
|
+
}
|
241
|
+
else
|
242
|
+
{
|
243
|
+
store.dispatch({type: 'LOADED_FILE', contents: defaultPath});
|
244
|
+
}
|
Binary file
|
@@ -0,0 +1,232 @@
|
|
1
|
+
atom-text-editor, :host {
|
2
|
+
background-color: #1d1f21;
|
3
|
+
color: #c5c8c6;
|
4
|
+
}
|
5
|
+
atom-text-editor .invisible-character, :host .invisible-character {
|
6
|
+
color: rgba(197, 200, 198, 0.2);
|
7
|
+
}
|
8
|
+
atom-text-editor .indent-guide, :host .indent-guide {
|
9
|
+
color: rgba(197, 200, 198, 0.2);
|
10
|
+
}
|
11
|
+
atom-text-editor .wrap-guide, :host .wrap-guide {
|
12
|
+
background-color: rgba(197, 200, 198, 0.1);
|
13
|
+
}
|
14
|
+
atom-text-editor .gutter, :host .gutter {
|
15
|
+
background-color: #292c2f;
|
16
|
+
}
|
17
|
+
atom-text-editor .gutter .cursor-line, :host .gutter .cursor-line {
|
18
|
+
background-color: rgba(255, 255, 255, 0.14);
|
19
|
+
}
|
20
|
+
atom-text-editor .line-number.cursor-line-no-selection, :host .line-number.cursor-line-no-selection {
|
21
|
+
background-color: rgba(255, 255, 255, 0.14);
|
22
|
+
}
|
23
|
+
atom-text-editor .gutter .line-number.folded, :host .gutter .line-number.folded, atom-text-editor .gutter .line-number:after, :host .gutter .line-number:after, atom-text-editor .fold-marker:after, :host .fold-marker:after {
|
24
|
+
color: #fba0e3;
|
25
|
+
}
|
26
|
+
atom-text-editor .invisible, :host .invisible {
|
27
|
+
color: #c5c8c6;
|
28
|
+
}
|
29
|
+
atom-text-editor .cursor, :host .cursor {
|
30
|
+
border-color: white;
|
31
|
+
}
|
32
|
+
atom-text-editor .selection .region, :host .selection .region {
|
33
|
+
background-color: #444;
|
34
|
+
}
|
35
|
+
atom-text-editor .source.gfm, :host .source.gfm {
|
36
|
+
color: #999;
|
37
|
+
}
|
38
|
+
atom-text-editor .gfm .markup.heading, :host .gfm .markup.heading {
|
39
|
+
color: #eee;
|
40
|
+
}
|
41
|
+
atom-text-editor .gfm .link, :host .gfm .link {
|
42
|
+
color: #555;
|
43
|
+
}
|
44
|
+
atom-text-editor .gfm .variable.list, :host .gfm .variable.list, atom-text-editor .gfm .support.quote, :host .gfm .support.quote {
|
45
|
+
color: #555;
|
46
|
+
}
|
47
|
+
atom-text-editor .gfm .link .entity, :host .gfm .link .entity {
|
48
|
+
color: #ddd;
|
49
|
+
}
|
50
|
+
atom-text-editor .gfm .raw, :host .gfm .raw {
|
51
|
+
color: #aaa;
|
52
|
+
}
|
53
|
+
atom-text-editor .markdown .paragraph, :host .markdown .paragraph {
|
54
|
+
color: #999;
|
55
|
+
}
|
56
|
+
atom-text-editor .markdown .heading, :host .markdown .heading {
|
57
|
+
color: #eee;
|
58
|
+
}
|
59
|
+
atom-text-editor .markdown .raw, :host .markdown .raw {
|
60
|
+
color: #aaa;
|
61
|
+
}
|
62
|
+
atom-text-editor .markdown .link, :host .markdown .link {
|
63
|
+
color: #555;
|
64
|
+
}
|
65
|
+
atom-text-editor .markdown .link .string, :host .markdown .link .string {
|
66
|
+
color: #555;
|
67
|
+
}
|
68
|
+
atom-text-editor .markdown .link .string.title, :host .markdown .link .string.title {
|
69
|
+
color: #ddd;
|
70
|
+
}
|
71
|
+
.bracket-matcher .region {
|
72
|
+
border-bottom: 1px solid #f8de7e;
|
73
|
+
margin-top: -1px;
|
74
|
+
opacity: .7;
|
75
|
+
}
|
76
|
+
.comment {
|
77
|
+
color: #7C7C7C;
|
78
|
+
}
|
79
|
+
.entity {
|
80
|
+
color: #FFD2A7;
|
81
|
+
}
|
82
|
+
.entity.name.type {
|
83
|
+
text-decoration: underline;
|
84
|
+
color: #FFFFB6;
|
85
|
+
}
|
86
|
+
.entity.other.inherited-class {
|
87
|
+
color: #9B5C2E;
|
88
|
+
}
|
89
|
+
.keyword {
|
90
|
+
color: #96CBFE;
|
91
|
+
}
|
92
|
+
.keyword.control {
|
93
|
+
color: #96CBFE;
|
94
|
+
}
|
95
|
+
.keyword.operator {
|
96
|
+
color: #EDEDED;
|
97
|
+
}
|
98
|
+
.storage {
|
99
|
+
color: #CFCB90;
|
100
|
+
}
|
101
|
+
.storage.modifier {
|
102
|
+
color: #96CBFE;
|
103
|
+
}
|
104
|
+
.constant {
|
105
|
+
color: #99CC99;
|
106
|
+
}
|
107
|
+
.constant.numeric {
|
108
|
+
color: #FF73FD;
|
109
|
+
}
|
110
|
+
.variable {
|
111
|
+
color: #C6C5FE;
|
112
|
+
}
|
113
|
+
.invalid.deprecated {
|
114
|
+
text-decoration: underline;
|
115
|
+
color: #FD5FF1;
|
116
|
+
}
|
117
|
+
.invalid.illegal {
|
118
|
+
color: #FD5FF1;
|
119
|
+
background-color: rgba(86, 45, 86, 0.75);
|
120
|
+
}
|
121
|
+
.string .source, .string .meta.embedded.line {
|
122
|
+
color: #EDEDED;
|
123
|
+
}
|
124
|
+
.string .punctuation.section.embedded {
|
125
|
+
color: #00A0A0;
|
126
|
+
}
|
127
|
+
.string .punctuation.section.embedded .source {
|
128
|
+
color: #00A0A0;
|
129
|
+
}
|
130
|
+
.string {
|
131
|
+
color: #A8FF60;
|
132
|
+
}
|
133
|
+
.string .constant {
|
134
|
+
color: #00A0A0;
|
135
|
+
}
|
136
|
+
.string.regexp {
|
137
|
+
color: #E9C062;
|
138
|
+
}
|
139
|
+
.string.regexp .constant.character.escape, .string.regexp .source.ruby.embedded, .string.regexp .string.regexp.arbitrary-repetition {
|
140
|
+
color: #FF8000;
|
141
|
+
}
|
142
|
+
.string.regexp.group {
|
143
|
+
color: #C6A24F;
|
144
|
+
background-color: rgba(255, 255, 255, 0.06);
|
145
|
+
}
|
146
|
+
.string.regexp.character-class {
|
147
|
+
color: #B18A3D;
|
148
|
+
}
|
149
|
+
.string .variable {
|
150
|
+
color: #8A9A95;
|
151
|
+
}
|
152
|
+
.support {
|
153
|
+
color: #FFFFB6;
|
154
|
+
}
|
155
|
+
.support.function {
|
156
|
+
color: #DAD085;
|
157
|
+
}
|
158
|
+
.support.constant {
|
159
|
+
color: #FFD2A7;
|
160
|
+
}
|
161
|
+
.support.type.property-name.css {
|
162
|
+
color: #EDEDED;
|
163
|
+
}
|
164
|
+
.source .entity.name.tag, .source .punctuation.tag {
|
165
|
+
color: #96CBFE;
|
166
|
+
}
|
167
|
+
.source .entity.other.attribute-name {
|
168
|
+
color: #C6C5FE;
|
169
|
+
}
|
170
|
+
.entity.other.attribute-name {
|
171
|
+
color: #C6C5FE;
|
172
|
+
}
|
173
|
+
.entity.name.tag.namespace, .entity.other.attribute-name.namespace {
|
174
|
+
color: #E18964;
|
175
|
+
}
|
176
|
+
.meta.preprocessor.c {
|
177
|
+
color: #8996A8;
|
178
|
+
}
|
179
|
+
.meta.preprocessor.c .keyword {
|
180
|
+
color: #AFC4DB;
|
181
|
+
}
|
182
|
+
.meta.cast {
|
183
|
+
color: #676767;
|
184
|
+
}
|
185
|
+
.meta.sgml.html .meta.doctype, .meta.sgml.html .meta.doctype .entity, .meta.sgml.html .meta.doctype .string, .meta.xml-processing, .meta.xml-processing .entity, .meta.xml-processing .string {
|
186
|
+
color: #494949;
|
187
|
+
}
|
188
|
+
.meta.tag .entity, .meta.tag > .punctuation, .meta.tag.inline .entity {
|
189
|
+
color: #C6C5FE;
|
190
|
+
}
|
191
|
+
.meta.tag .name, .meta.tag.inline .name, .meta.tag > .punctuation {
|
192
|
+
color: #96CBFE;
|
193
|
+
}
|
194
|
+
.meta.selector.css .entity.name.tag {
|
195
|
+
text-decoration: underline;
|
196
|
+
color: #96CBFE;
|
197
|
+
}
|
198
|
+
.meta.selector.css .entity.other.attribute-name.tag.pseudo-class {
|
199
|
+
color: #8F9D6A;
|
200
|
+
}
|
201
|
+
.meta.selector.css .entity.other.attribute-name.id {
|
202
|
+
color: #8B98AB;
|
203
|
+
}
|
204
|
+
.meta.selector.css .entity.other.attribute-name.class {
|
205
|
+
color: #62B1FE;
|
206
|
+
}
|
207
|
+
.meta.property-group .support.constant.property-value.css, .meta.property-value .support.constant.property-value.css {
|
208
|
+
color: #F9EE98;
|
209
|
+
}
|
210
|
+
.meta.preprocessor.at-rule .keyword.control.at-rule {
|
211
|
+
color: #8693A5;
|
212
|
+
}
|
213
|
+
.meta.property-value .support.constant.named-color.css, .meta.property-value .constant {
|
214
|
+
color: #87C38A;
|
215
|
+
}
|
216
|
+
.meta.constructor.argument.css {
|
217
|
+
color: #8F9D6A;
|
218
|
+
}
|
219
|
+
.meta.diff, .meta.diff.header {
|
220
|
+
color: #F8F8F8;
|
221
|
+
background-color: #0E2231;
|
222
|
+
}
|
223
|
+
.meta.separator {
|
224
|
+
color: #60A633;
|
225
|
+
background-color: #242424;
|
226
|
+
}
|
227
|
+
.meta.line.entry.logfile, .meta.line.exit.logfile {
|
228
|
+
background-color: rgba(238, 238, 238, 0.16);
|
229
|
+
}
|
230
|
+
.meta.line.error.logfile {
|
231
|
+
background-color: #751012;
|
232
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
|
4
|
+
|
5
|
+
*/
|
6
|
+
|
7
|
+
.hljs {
|
8
|
+
display: block;
|
9
|
+
overflow-x: auto;
|
10
|
+
padding: 0.5em;
|
11
|
+
background: #002b36;
|
12
|
+
color: #839496;
|
13
|
+
}
|
14
|
+
|
15
|
+
.hljs-comment,
|
16
|
+
.hljs-quote {
|
17
|
+
color: #586e75;
|
18
|
+
}
|
19
|
+
|
20
|
+
/* Solarized Green */
|
21
|
+
.hljs-keyword,
|
22
|
+
.hljs-selector-tag,
|
23
|
+
.hljs-addition {
|
24
|
+
color: #859900;
|
25
|
+
}
|
26
|
+
|
27
|
+
/* Solarized Cyan */
|
28
|
+
.hljs-number,
|
29
|
+
.hljs-string,
|
30
|
+
.hljs-meta .hljs-meta-string,
|
31
|
+
.hljs-literal,
|
32
|
+
.hljs-doctag,
|
33
|
+
.hljs-regexp {
|
34
|
+
color: #2aa198;
|
35
|
+
}
|
36
|
+
|
37
|
+
/* Solarized Blue */
|
38
|
+
.hljs-title,
|
39
|
+
.hljs-section,
|
40
|
+
.hljs-name,
|
41
|
+
.hljs-selector-id,
|
42
|
+
.hljs-selector-class {
|
43
|
+
color: #268bd2;
|
44
|
+
}
|
45
|
+
|
46
|
+
/* Solarized Yellow */
|
47
|
+
.hljs-attribute,
|
48
|
+
.hljs-attr,
|
49
|
+
.hljs-variable,
|
50
|
+
.hljs-template-variable,
|
51
|
+
.hljs-class .hljs-title,
|
52
|
+
.hljs-type {
|
53
|
+
color: #b58900;
|
54
|
+
}
|
55
|
+
|
56
|
+
/* Solarized Orange */
|
57
|
+
.hljs-symbol,
|
58
|
+
.hljs-bullet,
|
59
|
+
.hljs-subst,
|
60
|
+
.hljs-meta,
|
61
|
+
.hljs-meta .hljs-keyword,
|
62
|
+
.hljs-selector-attr,
|
63
|
+
.hljs-selector-pseudo,
|
64
|
+
.hljs-link {
|
65
|
+
color: #cb4b16;
|
66
|
+
}
|
67
|
+
|
68
|
+
/* Solarized Red */
|
69
|
+
.hljs-built_in,
|
70
|
+
.hljs-deletion {
|
71
|
+
color: #dc322f;
|
72
|
+
}
|
73
|
+
|
74
|
+
.hljs-formula {
|
75
|
+
background: #073642;
|
76
|
+
}
|
77
|
+
|
78
|
+
.hljs-emphasis {
|
79
|
+
font-style: italic;
|
80
|
+
}
|
81
|
+
|
82
|
+
.hljs-strong {
|
83
|
+
font-weight: bold;
|
84
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
body { background: black }
|
2
|
+
|
3
|
+
.hljs {
|
4
|
+
background: none;
|
5
|
+
}
|
6
|
+
|
7
|
+
pre {
|
8
|
+
color: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
#app {
|
12
|
+
display: flex;
|
13
|
+
flex-direction: row;
|
14
|
+
}
|
15
|
+
|
16
|
+
#main {
|
17
|
+
display: flex;
|
18
|
+
flex-direction: column;
|
19
|
+
}
|
20
|
+
|
21
|
+
#sidebar {
|
22
|
+
min-width: 400px;
|
23
|
+
padding-right: 30px;
|
24
|
+
}
|
25
|
+
|
26
|
+
#currently-viewing-path {
|
27
|
+
color: white;
|
28
|
+
font-family: monospace;
|
29
|
+
}
|
30
|
+
|
31
|
+
#fileviewer {
|
32
|
+
color: white;
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
li.file {
|
37
|
+
cursor: pointer;
|
38
|
+
}
|
39
|
+
|
40
|
+
li.file.active {
|
41
|
+
font-weight: bold;
|
42
|
+
background: #CCC;
|
43
|
+
display: inline-block;
|
44
|
+
}
|
45
|
+
|
46
|
+
li.file.active a {
|
47
|
+
color: black;
|
48
|
+
}
|
49
|
+
|
50
|
+
.copy {
|
51
|
+
color: transparent;;
|
52
|
+
background-size: contain;
|
53
|
+
background-image: url('/assets/copy.png');
|
54
|
+
background-repeat: no-repeat;
|
55
|
+
width: 50px;
|
56
|
+
height: 50px;
|
57
|
+
cursor: pointer;
|
58
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
/* From: http://www.thecssninja.com/css/css-tree-menu */
|
2
|
+
ol.tree {
|
3
|
+
padding: 0 0 0 30px;
|
4
|
+
width: 300px
|
5
|
+
}
|
6
|
+
|
7
|
+
li {
|
8
|
+
position: relative;
|
9
|
+
margin-left: -15px;
|
10
|
+
list-style: none
|
11
|
+
}
|
12
|
+
|
13
|
+
li.file {
|
14
|
+
margin-left: -1px!important;
|
15
|
+
font-family: monospace
|
16
|
+
}
|
17
|
+
|
18
|
+
li.file a {
|
19
|
+
/* document.png */
|
20
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYdJREFUeNqMksFqwkAQhmc3W4q0OSq09170LdJzb32IvkQVpIeeS6Gehdz6AkUoePOYe71VEBGiVkUxyaYzY9bENIYuTDbZ3f/b+Wci7ptNoCGEuMPpCsrHp9Z6qKMI4jjmBWVecL7utlqdHW4GFFpDhHtm3/M86PZ6D3QXxpchSqIlITSJgoBjt93CZr2G1WoFy+WS5/d2u4PnblF3YwAqQnEyBKElPs8sK006DCFEsO/78Oq64NTrby+u+4g7TwzQKUCSWDIG/kAcx2E7tm3Dh+fNDhmE2QwygCIIZcKvaDe1gBt5C9mRh9AlqCkE7C1ICZDcVASx9gCZWsgADhmUQCycwxMArgHXYZ9PIcTC9fDIAvY8nwHJTkHYQhCcsEAZYKvKIIJrmbGwGI/holo96oIugdC6sbCeTkEO+33wRyP6bVVSCD5kYOabumPW6SxpSEsXVL4Hg9piNjvPVPMgoKJRKCygUoq7QGdJQ1q6tYJR+5lM5peNxjP8Y+jNZk4aKsevAAMAmFzedjV8x2YAAAAASUVORK5CYII=) 0 0 no-repeat;
|
21
|
+
color: #fff;
|
22
|
+
padding-left: 21px;
|
23
|
+
text-decoration: none;
|
24
|
+
display: block
|
25
|
+
}
|
26
|
+
|
27
|
+
li.file {
|
28
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYdJREFUeNqMksFqwkAQhmc3W4q0OSq09170LdJzb32IvkQVpIeeS6Gehdz6AkUoePOYe71VEBGiVkUxyaYzY9bENIYuTDbZ3f/b+Wci7ptNoCGEuMPpCsrHp9Z6qKMI4jjmBWVecL7utlqdHW4GFFpDhHtm3/M86PZ6D3QXxpchSqIlITSJgoBjt93CZr2G1WoFy+WS5/d2u4PnblF3YwAqQnEyBKElPs8sK006DCFEsO/78Oq64NTrby+u+4g7TwzQKUCSWDIG/kAcx2E7tm3Dh+fNDhmE2QwygCIIZcKvaDe1gBt5C9mRh9AlqCkE7C1ICZDcVASx9gCZWsgADhmUQCycwxMArgHXYZ9PIcTC9fDIAvY8nwHJTkHYQhCcsEAZYKvKIIJrmbGwGI/holo96oIugdC6sbCeTkEO+33wRyP6bVVSCD5kYOabumPW6SxpSEsXVL4Hg9piNjvPVPMgoKJRKCygUoq7QGdJQ1q6tYJR+5lM5peNxjP8Y+jNZk4aKsevAAMAmFzedjV8x2YAAAAASUVORK5CYII=) 0 0 no-repeat
|
29
|
+
}
|
30
|
+
|
31
|
+
li input {
|
32
|
+
position: absolute;
|
33
|
+
left: 0;
|
34
|
+
margin-left: 0;
|
35
|
+
opacity: 0;
|
36
|
+
z-index: 2;
|
37
|
+
cursor: pointer;
|
38
|
+
height: 1em;
|
39
|
+
width: 1em;
|
40
|
+
top: 0
|
41
|
+
}
|
42
|
+
|
43
|
+
li input + ol {
|
44
|
+
/* toggle-small-expand.png */
|
45
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAURJREFUeNpi/P//PwMlgImBQkCxASwwRlLLKwYmJqZgRkbGbiBXEYva+0Dvlv7792/tvBoxTAO+fv0MororE6UU9VU5MHRfvP1DsX3+M5DhaxkYxDC98ObNGxBW1FVmY/j16xcYu6SdYvjw4QPDixcvGGSEvoLlQeqweuHdu7dg+vfv32D85ctXsNijR4/B4hwcnHA1WA348uUbmP779y+DUchOuIKQsltgetsUE7garAb8/w9h/vz5h+H0Sk8w2yRsN8OZVa5g9ocPn+BqsBrAzs4PdQEzw48ff+Fi375B2Gxs3HA1WNPB45NlDNzcIvfPXv8LVMwJxmdWOcDZF2//A8uD1GF1wefXZ8Q+Pt42oWN+VBED41d5DKv+/30IlJ8IVCcF5D2DCTPC8gIwAXEDKT4Qk0Di+wzU8xnDgKGbmQACDAAtTZadqmiADQAAAABJRU5ErkJggg==) 40px 0 no-repeat;
|
46
|
+
margin: -.938em 0 0 -44px;
|
47
|
+
/* 15px */
|
48
|
+
height: 1em
|
49
|
+
}
|
50
|
+
|
51
|
+
li input + ol > li {
|
52
|
+
display: none;
|
53
|
+
margin-left: -14px!important;
|
54
|
+
padding-left: 1px
|
55
|
+
}
|
56
|
+
|
57
|
+
li label {
|
58
|
+
/* folder-horizontal.png */
|
59
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAATNJREFUeNqkk71KA1EQhc/dOxsbEYukVYm9jQg+hz6CYGkrBNsEKwtrX0EfwU4UVFDLFWSDlYGAGszP3p91ZlNpdoVrBg572bnf2ZlhR+V5jnmCbo9VZTJS2ODHbkX63Od4Ij7ssdbKbvAFbB76o2GWYTAe42sywX7aQL8/xNnjYsRXttR1G+3tg4tW7twPWGmNXvJcnBvrzRlzyd+c7nTIeWjPXxD9jjqDb0mC9O6+tAdhpwbWQDTTwsCgvrpSCksFr1dsYAsDC1diUETFe11bgC0qcCBnMoiCQikIS9ZxBcawgQnkIwgrBiT9h1YQRYUBkfFTA2/DKvA8RGGJ5xf/OcSK0JogLH2MsCS/VKzjsBZYwtJDiu7nSevyP4v00kNXNqnGWpbFCuQt613Nu87fAgwAb3KTD1NdyNYAAAAASUVORK5CYII=) 15px 1px no-repeat;
|
60
|
+
cursor: pointer;
|
61
|
+
display: block;
|
62
|
+
padding-left: 37px;
|
63
|
+
color: #fff;
|
64
|
+
font-family: monospace
|
65
|
+
}
|
66
|
+
|
67
|
+
li input:checked + ol {
|
68
|
+
/* toggle-small.png */
|
69
|
+
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAASxJREFUeNpi/P//PwMlgImBQkCxASwwRlLLKwYmJqZgRkbGbiBXEYva+0Dvlv7792/tvBoxTAO+fv0MororE6UU9VU5MHRfvP1DsX3+M5DhaxkYsBjw5s0bEKWoq6zA8OvXL7AYKIC/f//O8OPHDwYZIVaQGqjLlDENePfuLZj+/fs3GH/58pXh/fv3YDYIcHBwwtVgDYMvX76B6b9//zIYhezEULhtiglcDVYD/v+HMH/+/MNweqUnhsIPHz7B1WA1gJ2dH+oCZqCf/2IoZGPjhqvBmg4enyxj4OYWuX/2+l+gYk4MfPH2P7A8SB1WF3x+fUbs4+NtEzrmRxUxMH6Vx7Dq/9+HQPmJQHVSQN4zmDAjLC8AExA3kOIDMQkkvs9APZ8xDBi6mQkgwADDMYZH9Ls66AAAAABJRU5ErkJggg==) 40px 5px no-repeat;
|
70
|
+
margin: -1.25em 0 0 -44px;
|
71
|
+
/* 20px */
|
72
|
+
padding: 1.563em 0 0 80px;
|
73
|
+
height: auto
|
74
|
+
}
|
75
|
+
|
76
|
+
li.file {
|
77
|
+
margin: 0 0 0.25em 0.25em;
|
78
|
+
}
|
79
|
+
|
80
|
+
li input:checked + ol > li {
|
81
|
+
display: block;
|
82
|
+
margin: 0 0 0.25em 0.25em;
|
83
|
+
}
|
84
|
+
|
85
|
+
li input:checked + ol > li:last-child {
|
86
|
+
margin: 0 0 .063em
|
87
|
+
/* 1px */
|
88
|
+
}
|
data/lib/tree.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module CodeServer
|
4
|
+
class Tree
|
5
|
+
attr_accessor :root_path
|
6
|
+
|
7
|
+
def initialize(root_path)
|
8
|
+
self.root_path = root_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def directory_structure
|
12
|
+
if %x{git rev-parse 2>&1}.empty?
|
13
|
+
data = %x{cd #{root_path}; git ls-files 2>/dev/null; git ls-files --exclude-standard --others 2>/dev/null}.split("\n")
|
14
|
+
else
|
15
|
+
data = %x{cd #{root_path}; find . | cut -c3-}
|
16
|
+
end
|
17
|
+
|
18
|
+
tree = { files: [], directories: [] }
|
19
|
+
data.each do |line|
|
20
|
+
current_tree = tree
|
21
|
+
|
22
|
+
*directories, file = line.split("/")
|
23
|
+
|
24
|
+
path = "."
|
25
|
+
while directory = directories.shift do
|
26
|
+
path << "/#{directory}"
|
27
|
+
|
28
|
+
subdirectory = current_tree[:directories].find { |entry| entry[:name] == directory }
|
29
|
+
if subdirectory.nil?
|
30
|
+
subdirectory = { name: directory, path: path, directories: [], files: [] }
|
31
|
+
current_tree[:directories] << subdirectory
|
32
|
+
end
|
33
|
+
|
34
|
+
current_tree = subdirectory
|
35
|
+
end
|
36
|
+
|
37
|
+
current_tree[:files] << { name: file, path: "./#{line}" }
|
38
|
+
end
|
39
|
+
|
40
|
+
tree
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if $0 == __FILE__
|
46
|
+
puts CodeServer::Tree.new("..").directory_structure.to_json
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" type='text/css' href="/assets/solarized-dark.css">
|
4
|
+
<link rel='stylesheet' type='text/css' href='/assets/style.css'/>
|
5
|
+
<link rel='stylesheet' type='text/css' href='/assets/editor.css'/>
|
6
|
+
<link rel='stylesheet' type='text/css' href='/assets/tree.css'/>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<% if @path %>
|
10
|
+
<div id="root" data-path="<%= @path %>"></div>
|
11
|
+
<% else %>
|
12
|
+
<div id="root"></div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<script src='/dist/bundle.js'></script>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module.exports = {
|
2
|
+
entry: "./public/assets/app.jsx",
|
3
|
+
output: {
|
4
|
+
path: 'public/dist',
|
5
|
+
filename: "bundle.js"
|
6
|
+
},
|
7
|
+
module: {
|
8
|
+
loaders: [
|
9
|
+
{ test: /\.css$/, loader: "style!css" },
|
10
|
+
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel"}
|
11
|
+
]
|
12
|
+
}
|
13
|
+
};
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codeserver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gavin Stark
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sinatra
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra-websocket
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rb-fsevent
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Serves your local directory of code with a navigatable project tree and
|
98
|
+
code formatting
|
99
|
+
email:
|
100
|
+
- gavin@gstark.com
|
101
|
+
executables:
|
102
|
+
- codeserver
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- Procfile
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/setup
|
115
|
+
- codeserver.gemspec
|
116
|
+
- exe/codeserver
|
117
|
+
- lib/.babelrc
|
118
|
+
- lib/codeserver.rb
|
119
|
+
- lib/codeserver/version.rb
|
120
|
+
- lib/file_extensions.rb
|
121
|
+
- lib/package.json
|
122
|
+
- lib/public/assets/app.jsx
|
123
|
+
- lib/public/assets/copy.png
|
124
|
+
- lib/public/assets/editor.css
|
125
|
+
- lib/public/assets/solarized-dark.css
|
126
|
+
- lib/public/assets/style.css
|
127
|
+
- lib/public/assets/tree.css
|
128
|
+
- lib/public/dist/bundle.js
|
129
|
+
- lib/tree.rb
|
130
|
+
- lib/views/index.html.erb
|
131
|
+
- lib/webpack.config.js
|
132
|
+
homepage: https://github.com/gstark/code-server
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.5.1
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Serves your local directory of code with a navigatable project tree and code
|
156
|
+
formatting
|
157
|
+
test_files: []
|