12 Commits
9 changed files with 150 additions and 49 deletions
+1
View File
@@ -12,6 +12,7 @@ tags
chat chat
spelling spelling
real-time real-time
migrations/*.js
data data
tmp tmp
+21
View File
@@ -0,0 +1,21 @@
v0.1.3
------
* Fix bug with large files being corrupted when downloaded.
* Update Ace editor to lastest release.
* Lots of added null checks in the front-end javascript.
* Don't crash if 'unzip' program isn't present.
* Allow track-changes history to be packed into compressed 'packs'. This must be done manually for now.
* Escape any shell special characters in the CLSI root path.
v0.1.2
------
* Re-brand open-source ShareLaTeX code as 'ShareLaTeX Community Edition'.
* The Dropbox and template code has been extracted out into a separate module and removed from the ShareLaTeX Community Edition. There should be no broken features due to lack of open source components now.
* Websockets and real-time data now go to a separate light-weight [real-time](https://github.com/sharelatex/real-time) service.
* Updated PDF viewer that loads page-by-page for much quicker loading times on large documents.
* Links are clickable in chat messages.
* Mathjax libraries are now served locally.
* Optimisation of Angular digest loop in editor should reduce CPU usage in certain cases.
* Numerous small bug fixes.
+17 -12
View File
@@ -7,47 +7,49 @@ semver = require "semver"
knox = require "knox" knox = require "knox"
crypto = require "crypto" crypto = require "crypto"
async = require "async" async = require "async"
settings = require("settings-sharelatex")
SERVICES = [{ SERVICES = [{
name: "web" name: "web"
repo: "https://github.com/sharelatex/web-sharelatex.git" repo: "https://github.com/sharelatex/web-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "real-time" name: "real-time"
repo: "https://github.com/sharelatex/real-time-sharelatex.git" repo: "https://github.com/sharelatex/real-time-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "document-updater" name: "document-updater"
repo: "https://github.com/sharelatex/document-updater-sharelatex.git" repo: "https://github.com/sharelatex/document-updater-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "clsi" name: "clsi"
repo: "https://github.com/sharelatex/clsi-sharelatex.git" repo: "https://github.com/sharelatex/clsi-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "filestore" name: "filestore"
repo: "https://github.com/sharelatex/filestore-sharelatex.git" repo: "https://github.com/sharelatex/filestore-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "track-changes" name: "track-changes"
repo: "https://github.com/sharelatex/track-changes-sharelatex.git" repo: "https://github.com/sharelatex/track-changes-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "docstore" name: "docstore"
repo: "https://github.com/sharelatex/docstore-sharelatex.git" repo: "https://github.com/sharelatex/docstore-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "chat" name: "chat"
repo: "https://github.com/sharelatex/chat-sharelatex.git" repo: "https://github.com/sharelatex/chat-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "tags" name: "tags"
repo: "https://github.com/sharelatex/tags-sharelatex.git" repo: "https://github.com/sharelatex/tags-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}, { }, {
name: "spelling" name: "spelling"
repo: "https://github.com/sharelatex/spelling-sharelatex.git" repo: "https://github.com/sharelatex/spelling-sharelatex.git"
version: "v0.1.2" version: "v0.1.3"
}] }]
module.exports = (grunt) -> module.exports = (grunt) ->
@@ -56,6 +58,7 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-available-tasks' grunt.loadNpmTasks 'grunt-available-tasks'
grunt.loadNpmTasks 'grunt-concurrent' grunt.loadNpmTasks 'grunt-concurrent'
grunt.loadNpmTasks "grunt-contrib-coffee" grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-shell"
execute = {} execute = {}
@@ -83,7 +86,9 @@ module.exports = (grunt) ->
options: options:
bare:true bare:true
shell:
migrate:
command: "./node_modules/east/bin/east migrate --adapter east-mongo --url #{settings?.mongo?.url}"
availabletasks: availabletasks:
tasks: tasks:
@@ -162,7 +167,7 @@ module.exports = (grunt) ->
Helpers.buildUpstartScripts() Helpers.buildUpstartScripts()
grunt.registerTask 'migrate', 'run migrations', ['coffee:migrate'] #grunt.registerTask 'migrate', "compile migrations and run them", ['coffee:migrate', 'shell:migrate']
Helpers = Helpers =
+5
View File
@@ -15,6 +15,11 @@ We have detailed installation instructions in our wiki:
**If you have any problems, have a look at our page of [Frequent Problems and Questions](https://github.com/sharelatex/sharelatex/wiki/FAQ).** **If you have any problems, have a look at our page of [Frequent Problems and Questions](https://github.com/sharelatex/sharelatex/wiki/FAQ).**
Upgrading
---------
If you are upgrading from a previous version of ShareLaTeX, please see the [Release Notes section on the Wiki] (https://github.com/sharelatex/sharelatex/wiki/Home) for all of the versions between your current version and the version you are upgrading to.
Dependencies Dependencies
------------ ------------
@@ -93,6 +93,14 @@ module.exports =
# when emails are sent out and in generated links: # when emails are sent out and in generated links:
siteUrl : 'http://localhost:3000' siteUrl : 'http://localhost:3000'
# The websocket layer of ShareLaTeX runs as separate service.
# When running locally or in development, you can point the client to this
# service directly on port 3026. If you are running behind a reverse proxy (Nginx, etc)
# then websocketsUrl should be the same as siteUrl, with your reverse
# proxy responible for sending websocket traffic to the websocket service
# rather than connecting directly.
websocketsUrl: 'http://localhost:3026'
# If provided, a sessionSecret is used to sign cookies so that they cannot be # If provided, a sessionSecret is used to sign cookies so that they cannot be
# spoofed. This is recommended. # spoofed. This is recommended.
security: security:
@@ -1,31 +1,32 @@
Settings = require "settings-sharelatex"
fs = require("fs") fs = require("fs")
mongojs = require("mongojs") mongojs = require("mongojs")
ObjectId = mongojs.ObjectId ObjectId = mongojs.ObjectId
db = mongojs('sharelatex', ['projects', 'docs']) console.log Settings.mongo.url
db = mongojs(Settings.mongo.url, ['projects', 'docs'])
_ = require("lodash") _ = require("lodash")
async = require("async") async = require("async")
exec = require("child_process").exec exec = require("child_process").exec
finished_projects_path = "/tmp/finished-projects" finished_projects_path = "/tmp/finished-projects"
all_projects_path = "/tmp/all-projects" all_projects_path = "/tmp/all-projects"
project_too_large_path = "/tmp/large_projects"
printProgress = -> printProgress = ->
exec "wc #{finished_projects_path}", (error, results) -> exec "wc #{finished_projects_path}", (error, results) ->
#console.log results
setTimeout printProgress, 1000 * 30 setTimeout printProgress, 1000 * 30
checkIfFileHasBeenProccessed = (project_id, callback)-> checkIfFileHasBeenProccessed = (project_id, callback)->
exec "grep #{project_id} #{finished_projects_path}", (error, results) -> exec "grep #{project_id} #{finished_projects_path}", (error, results) ->
hasBeenProcessed = _.include(results, project_id) hasBeenProcessed = _.include(results, project_id)
#console.log hasBeenProcessed, project_id callback(error, hasBeenProcessed)
callback(null, hasBeenProcessed)
loadProjectIds = (callback)-> loadProjectIds = (callback)->
console.log "loading project ids from #{all_projects_path}"
fs.readFile all_projects_path, "utf-8", (err, data)-> fs.readFile all_projects_path, "utf-8", (err, data)->
console.log data.length
ids = data.split("\n") ids = data.split("\n")
console.log ids.length console.log "loaded #{ids.length} project ids from #{all_projects_path}"
callback err, ids callback err, ids
getAndWriteProjectids = (callback)-> getAndWriteProjectids = (callback)->
@@ -38,9 +39,14 @@ getAndWriteProjectids = (callback)->
fs.writeFile all_projects_path, fileData, -> fs.writeFile all_projects_path, fileData, ->
callback(err, ids) callback(err, ids)
markProjectAsToLargeAndFinished = (project_id, callback)->
console.log "#{project_id} too large"
markProjectAsProcessed project_id, (err)->
fs.appendFile project_too_large_path, "#{project_id}\n", callback
getProjectIds = (callback)-> getProjectIds = (callback)->
exists = fs.existsSync all_projects_path exists = fs.existsSync all_projects_path
if exists if exists
loadProjectIds callback loadProjectIds callback
else else
getAndWriteProjectids callback getAndWriteProjectids callback
@@ -52,8 +58,11 @@ getAllDocs = (project_id, callback = (error, docs) ->) ->
db.projects.findOne _id:ObjectId(project_id), (error, project) -> db.projects.findOne _id:ObjectId(project_id), (error, project) ->
return callback(error) if error? return callback(error) if error?
if !project? if !project?
console.error("No such project: #{project_id}") console.log "no such project #{project_id}"
return callback("no such project #{project_id}") return callback()
size = require("../node_modules/mongojs/node_modules/mongodb/node_modules/bson/").BSONPure.BSON.calculateObjectSize(project)
if size > 12000000 #12mb
return markProjectAsToLargeAndFinished project_id, callback
findAllDocsInProject project, (error, docs) -> findAllDocsInProject project, (error, docs) ->
return callback(error) if error? return callback(error) if error?
return callback null, docs return callback null, docs
@@ -82,17 +91,33 @@ _findAllDocsInFolder = (folder = {}) ->
return docs return docs
insertDocIntoDocCollection = (project_id, doc_id, lines, oldRev, callback)-> insertDocIntoDocCollection = (project_id, doc_id, lines, oldRev, callback)->
if !project_id?
return callback("no project id")
if !doc_id?
return callback()
if !lines?
lines = [""]
update = {} update = {}
update["_id"] = ObjectId(doc_id) update["_id"] = ObjectId(doc_id.toString())
update["lines"] = lines update["lines"] = lines
update["project_id"] = ObjectId(project_id) update["project_id"] = ObjectId(project_id)
update["rev"] = oldRev update["rev"] = oldRev || 0
db.docs.insert _id: ObjectId(doc_id), callback db.docs.insert update, callback
saveDocsIntoMongo = (project_id, docs, callback)-> saveDocsIntoMongo = (project_id, docs, callback)->
jobs = _.map docs, (doc)-> jobs = _.map docs, (doc)->
(cb)-> (cb)->
insertDocIntoDocCollection project_id, doc._id, project_id.lines, doc.rev, cb if !doc?
console.error "null doc in project #{project_id}" #just skip it, not a big deal
return cb()
insertDocIntoDocCollection project_id, doc._id, doc.lines, doc.rev, (err)->
if err?.code == 11000 #duplicate key, doc already in there so its not a problem.
err = undefined
if err?
console.log "error inserting doc into doc collection", err
cb(err)
async.series jobs, callback async.series jobs, callback
@@ -101,33 +126,36 @@ processNext = (project_id, callback)->
if hasBeenProcessed if hasBeenProcessed
console.log "#{project_id} already procssed, skipping" console.log "#{project_id} already procssed, skipping"
return callback() return callback()
console.log "#{project_id} processing"
getAllDocs project_id, (err, docs)-> getAllDocs project_id, (err, docs)->
if err? if err?
console.error err, project_id, "could not get all docs" console.error err, project_id, "could not get all docs"
return callback() return callback(err)
saveDocsIntoMongo project_id, docs, -> else
if err? saveDocsIntoMongo project_id, docs, (err)->
console.error err, project_id, "could not save docs into mongo" if err?
return callback() console.error err, project_id, "could not save docs into mongo"
markProjectAsProcessed project_id, -> return callback(err)
callback() markProjectAsProcessed project_id, (err)->
setTimeout(
-> callback(err)
,500)
getProjectIds (err, ids)->
printProgress()
jobs = _.map ids, (id)->
return (cb)->
processNext(id, cb)
async.series jobs, (err)->
if err?
console.error err, "at end of jobs"
else
console.log "finished"
process.exit()
exports.up = (next)->
next()
exports.migrate = (client, done = ->)->
getProjectIds (err, ids)->
printProgress()
jobs = _.map ids, (id)->
return (cb)->
processNext(id, cb)
async.series jobs, (err)->
if err?
console.error err, "at end of jobs"
else
console.log "finished"
done(err)
exports.down = (next)->
exports.rollback = (next)->
next() next()
+2
View File
@@ -0,0 +1,2 @@
* if migration is stopped mid way it will start at the beginging next time
* to see the run migrations do db.getCollection('_migrations').find() you can't do db._migrations.find()
+4 -1
View File
@@ -1,9 +1,12 @@
{ {
"name": "sharelatex", "name": "sharelatex",
"version": "0.1.2", "version": "0.1.3",
"description": "An online collaborative LaTeX editor", "description": "An online collaborative LaTeX editor",
"dependencies": { "dependencies": {
"async": "^0.9.0", "async": "^0.9.0",
"east": "^0.2.3",
"east-mongo": "^0.1.2",
"grunt-shell": "^1.1.1",
"lodash": "^3.0.0", "lodash": "^3.0.0",
"mongojs": "^0.18.1", "mongojs": "^0.18.1",
"rimraf": "~2.2.6", "rimraf": "~2.2.6",
+28
View File
@@ -0,0 +1,28 @@
description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on shutdown
respawn
limit nofile 8192 8192
pre-start script
mkdir -p /var/log/sharelatex
end script
script
SERVICE=real-time
USER=sharelatex
GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
LATEX_PATH=/usr/local/texlive/2014/bin/x86_64-linux
echo $$ > /var/run/sharelatex-$SERVICE.pid
cd /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production PATH=$PATH:$LATEX_PATH $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script