Merge branch 'master' of github.com:sharelatex/web-sharelatex

This commit is contained in:
Shane Kilkelly 2016-01-20 14:02:24 +00:00
commit d5d5ba9066
7 changed files with 101 additions and 39 deletions

View file

@ -111,8 +111,11 @@ module.exports = ClsiManager =
ClsiManager._buildRequest project_id, options, (error, req) -> ClsiManager._buildRequest project_id, options, (error, req) ->
compilerUrl = ClsiManager._getCompilerUrl(options?.compileGroup) compilerUrl = ClsiManager._getCompilerUrl(options?.compileGroup)
filename = file || req?.compile?.rootResourcePath filename = file || req?.compile?.rootResourcePath
wordcount_url = "#{compilerUrl}/project/#{project_id}/wordcount?file=#{encodeURIComponent(filename)}"
if req.compile.options.imageName?
wordcount_url += "&image=#{encodeURIComponent(req.compile.options.imageName)}"
request.get { request.get {
url: "#{compilerUrl}/project/#{project_id}/wordcount?file=#{filename}" url: wordcount_url
}, (error, response, body) -> }, (error, response, body) ->
return callback(error) if error? return callback(error) if error?
if 200 <= response.statusCode < 300 if 200 <= response.statusCode < 300

View file

@ -26,6 +26,8 @@ module.exports = ProjectEditorHandler =
dropbox:false dropbox:false
compileTimeout: 60 compileTimeout: 60
compileGroup:"standard" compileGroup:"standard"
templates: false
references: false
if project.owner_ref.features? if project.owner_ref.features?
if project.owner_ref.features.collaborators? if project.owner_ref.features.collaborators?
@ -37,7 +39,11 @@ module.exports = ProjectEditorHandler =
if project.owner_ref.features.compileTimeout? if project.owner_ref.features.compileTimeout?
result.features.compileTimeout = project.owner_ref.features.compileTimeout result.features.compileTimeout = project.owner_ref.features.compileTimeout
if project.owner_ref.features.compileGroup? if project.owner_ref.features.compileGroup?
result.features.compileGroup = project.owner_ref.features.compileGroup result.features.compileGroup = project.owner_ref.features.compileGroup
if project.owner_ref.features.templates?
result.features.templates = project.owner_ref.features.templates
if project.owner_ref.features.references?
result.features.references = project.owner_ref.features.references
result.owner = @buildUserModelView project.owner_ref, "owner" result.owner = @buildUserModelView project.owner_ref, "owner"

View file

@ -13,6 +13,7 @@ module.exports =
webRouter.get '/privacy_policy', HomeController.externalPage("privacy", "Privacy Policy") webRouter.get '/privacy_policy', HomeController.externalPage("privacy", "Privacy Policy")
webRouter.get '/planned_maintenance', HomeController.externalPage("planned_maintenance", "Planned Maintenance") webRouter.get '/planned_maintenance', HomeController.externalPage("planned_maintenance", "Planned Maintenance")
webRouter.get '/style', HomeController.externalPage("style_guide", "Style Guide") webRouter.get '/style', HomeController.externalPage("style_guide", "Style Guide")
webRouter.get '/jobs', HomeController.externalPage("jobs", "Jobs")
webRouter.get '/dropbox', HomeController.externalPage("dropbox", "Dropbox and ShareLaTeX") webRouter.get '/dropbox', HomeController.externalPage("dropbox", "Dropbox and ShareLaTeX")

View file

@ -34,6 +34,8 @@ UserSchema = new Schema
github: { type:Boolean, default: Settings.defaultFeatures.github } github: { type:Boolean, default: Settings.defaultFeatures.github }
compileTimeout: { type:Number, default: Settings.defaultFeatures.compileTimeout } compileTimeout: { type:Number, default: Settings.defaultFeatures.compileTimeout }
compileGroup: { type:String, default: Settings.defaultFeatures.compileGroup } compileGroup: { type:String, default: Settings.defaultFeatures.compileGroup }
templates: { type:Boolean, default: Settings.defaultFeatures.templates }
references: { type:Boolean, default: Settings.defaultFeatures.references }
} }
featureSwitches : { featureSwitches : {
pdfng: { type: Boolean } pdfng: { type: Boolean }

View file

@ -6,46 +6,84 @@ script(type="text/ng-template", id="publishProjectAsTemplateModalTemplate")
ng-click="cancel()" ng-click="cancel()"
) &times; ) &times;
h3 #{translate("publish_as_template")} h3 #{translate("publish_as_template")}
.modal-body.modal-body-share div(ng-if="project.features.templates")
span(ng-hide="problemTalkingToTemplateApi") .modal-body.modal-body-share
form() span(ng-hide="problemTalkingToTemplateApi")
label(for='Description') #{translate("template_description")} form()
.form-group label(for='Description') #{translate("template_description")}
textarea.form-control( .form-group
rows=5, textarea.form-control(
name='Description', rows=5,
ng-model="templateDetails.description", name='Description',
value="" ng-model="templateDetails.description",
) value=""
div(ng-show="templateDetails.exists").text-center.templateDetails )
| #{translate("project_last_published_at")} div(ng-show="templateDetails.exists").text-center.templateDetails
strong {{templateDetails.publishedDate}}. | #{translate("project_last_published_at")}
a(ng-href="{{templateDetails.canonicalUrl}}") #{translate("view_in_template_gallery")}. strong {{templateDetails.publishedDate}}.
a(ng-href="{{templateDetails.canonicalUrl}}") #{translate("view_in_template_gallery")}.
span(ng-show="problemTalkingToTemplateApi") #{translate("problem_talking_to_publishing_service")}. span(ng-show="problemTalkingToTemplateApi") #{translate("problem_talking_to_publishing_service")}.
.modal-footer(ng-hide="problemTalkingToTemplateApi")
button.btn.btn-default(
ng-click="cancel()",
ng-disabled="state.publishInflight || state.unpublishInflight"
)
span #{translate("cancel")}
button.btn.btn-info(
ng-click="unpublishTemplate()",
ng-disabled="state.publishInflight || state.unpublishInflight"
ng-show="templateDetails.exists"
)
span(ng-show="!state.unpublishInflight") #{translate("unpublish")}
span(ng-show="state.unpublishInflight") #{translate("unpublishing")}...
button.btn.btn-primary(
ng-click="publishTemplate()",
ng-disabled="state.publishInflight || state.unpublishInflight"
)
span(ng-show="!state.publishInflight && !templateDetails.exists") #{translate("publish")}
span(ng-show="!state.publishInflight && templateDetails.exists") #{translate("republish")}
span(ng-show="state.publishInflight") #{translate("publishing")}...
div(ng-hide="project.features.templates")
.modal-body.modal-body-share
p #{translate("upgrade_to_get_feature", {feature:"templates"})}
.modal-footer(ng-hide="problemTalkingToTemplateApi") ul.list-unstyled
button.btn.btn-default( li
ng-click="cancel()", i.fa.fa-check &nbsp;
ng-disabled="state.publishInflight || state.unpublishInflight" | #{translate("unlimited_projects")}
)
span #{translate("cancel")} li
i.fa.fa-check &nbsp;
| #{translate("collabs_per_proj", {collabcount:'Multiple'})}
li
i.fa.fa-check &nbsp;
| #{translate("full_doc_history")}
li
i.fa.fa-check &nbsp;
| #{translate("sync_to_dropbox")}
button.btn.btn-info( li
ng-click="unpublishTemplate()", i.fa.fa-check &nbsp;
ng-disabled="state.publishInflight || state.unpublishInflight" | #{translate("sync_to_github")}
ng-show="templateDetails.exists"
)
span(ng-show="!state.unpublishInflight") #{translate("unpublish")}
span(ng-show="state.unpublishInflight") #{translate("unpublishing")}...
button.btn.btn-primary( li
ng-click="publishTemplate()", i.fa.fa-check &nbsp;
ng-disabled="state.publishInflight || state.unpublishInflight" |#{translate("compile_larger_projects")}
)
span(ng-show="!state.publishInflight && !templateDetails.exists") #{translate("publish")} .modal-footer(ng-controller="FreeTrialModalController")
span(ng-show="!state.publishInflight && templateDetails.exists") #{translate("republish")} .text-center
span(ng-show="state.publishInflight") #{translate("publishing")}... a.btn.btn-success(
href
ng-class="buttonClass"
ng-click="startFreeTrial('templates')"
) #{translate("start_free_trial")}
.row-spaced-small.small(ng-show="startedFreeTrial")
| #{translate("refresh_page_after_starting_free_trial")}

View file

@ -143,6 +143,8 @@ module.exports =
versioning: true versioning: true
compileTimeout: 60 compileTimeout: 60
compileGroup: "standard" compileGroup: "standard"
references: true
templates: true
plans: plans = [{ plans: plans = [{
planCode: "personal" planCode: "personal"

View file

@ -266,7 +266,7 @@ describe "ClsiManager", ->
describe "wordCount", -> describe "wordCount", ->
beforeEach -> beforeEach ->
@request.get = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body = { mock: "foo" }) @request.get = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body = { mock: "foo" })
@ClsiManager._buildRequest = sinon.stub().callsArgWith(2, null, { compile: { rootResourcePath: "rootfile.text" } }) @ClsiManager._buildRequest = sinon.stub().callsArgWith(2, null, @req = { compile: { rootResourcePath: "rootfile.text", options: {} } })
@ClsiManager._getCompilerUrl = sinon.stub().returns "compiler.url" @ClsiManager._getCompilerUrl = sinon.stub().returns "compiler.url"
describe "with root file", -> describe "with root file", ->
@ -289,3 +289,13 @@ describe "ClsiManager", ->
@request.get @request.get
.calledWith({ url: "compiler.url/project/#{@project_id}/wordcount?file=main.tex" }) .calledWith({ url: "compiler.url/project/#{@project_id}/wordcount?file=main.tex" })
.should.equal true .should.equal true
describe "with image", ->
beforeEach ->
@req.compile.options.imageName = @image = "example.com/mock/image"
@ClsiManager.wordCount @project_id, "main.tex", {}, @callback
it "should call wordCount with file and image", ->
@request.get
.calledWith({ url: "compiler.url/project/#{@project_id}/wordcount?file=main.tex&image=#{encodeURIComponent(@image)}" })
.should.equal true