Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use linked google fonts and mathjax when publishing to rpubs

  • Loading branch information...
commit 1bb14e1c322883a663876b15bf821620865d6228 1 parent 317212b
@jjallaire jjallaire authored
View
32 src/cpp/session/modules/presentation/SessionPresentation.cpp
@@ -30,6 +30,8 @@
#include <session/SessionModuleContext.hpp>
#include <session/projects/SessionProjects.hpp>
+#include "../SessionRPubs.hpp"
+
#include "PresentationState.hpp"
#include "SlideRequestHandler.hpp"
@@ -190,6 +192,35 @@ Error createStandalonePresentation(const json::JsonRpcRequest& request,
return Success();
}
+Error createPresentationRpubsSource(const json::JsonRpcRequest& request,
+ json::JsonRpcResponse* pResponse)
+{
+ // use a stable location in the presentation directory for the Rpubs
+ // source file so that update works across sessions
+ FilePath filePath = presentation::state::directory().childPath(
+ "slides-rpubs.html");
+
+ std::string errMsg;
+ if (savePresentationAsRpubsSource(filePath, &errMsg))
+ {
+ json::Object resultJson;
+ resultJson["published"] = !rpubs::previousUploadId(filePath).empty();
+ resultJson["source_file_path"] = module_context::createAliasedPath(
+ filePath);
+ pResponse->setResult(resultJson);
+ }
+ else
+ {
+ pResponse->setError(systemError(boost::system::errc::io_error,
+ ERROR_LOCATION),
+ json::toJsonString(errMsg));
+ }
+
+ return Success();
+}
+
+
+
} // anonymous namespace
@@ -220,6 +251,7 @@ Error initialize()
initBlock.addFunctions()
(bind(registerUriHandler, "/presentation", handlePresentationPaneRequest))
(bind(registerRpcMethod, "create_standalone_presentation", createStandalonePresentation))
+ (bind(registerRpcMethod, "create_presentation_rpubs_source", createPresentationRpubsSource))
(bind(registerRpcMethod, "set_presentation_slide_index", setPresentationSlideIndex))
(bind(registerRpcMethod, "close_presentation_pane", closePresentationPane))
(bind(registerRpcMethod, "presentation_execute_code", presentationExecuteCode))
View
7 src/cpp/session/modules/presentation/SlideRequestHandler.cpp
@@ -968,6 +968,13 @@ bool savePresentationAsStandalone(core::FilePath* pFilePath,
pErrMsg);
}
+bool savePresentationAsRpubsSource(const core::FilePath& filePath,
+ std::string* pErrMsg)
+{
+ return createStandalonePresentation(filePath, publishToRPubsVars, pErrMsg);
+}
+
+
} // namespace presentation
View
3  src/cpp/session/modules/presentation/SlideRequestHandler.hpp
@@ -42,6 +42,9 @@ void handlePresentationHelpRequest(const core::http::Request& request,
bool savePresentationAsStandalone(core::FilePath* pFilePath,
std::string* pErrMsg);
+bool savePresentationAsRpubsSource(const core::FilePath& filePath,
+ std::string* pErrMsg);
+
} // namespace presentation
} // namespace modules
} // namesapce session
View
11 src/gwt/src/org/rstudio/studio/client/server/remote/RemoteServer.java
@@ -73,6 +73,7 @@
import org.rstudio.studio.client.workbench.views.packages.model.PackageUpdate;
import org.rstudio.studio.client.workbench.views.plots.model.Point;
import org.rstudio.studio.client.workbench.views.plots.model.SavePlotAsImageContext;
+import org.rstudio.studio.client.workbench.views.presentation.model.PresentationRPubsSource;
import org.rstudio.studio.client.workbench.views.source.editors.text.IconvListResult;
import org.rstudio.studio.client.workbench.views.source.model.CheckForExternalEditResult;
import org.rstudio.studio.client.workbench.views.source.model.RdShellResult;
@@ -2551,6 +2552,15 @@ public void createStandalonePresentation(
}
@Override
+ public void createPresentationRPubsSource(
+ ServerRequestCallback<PresentationRPubsSource> requestCallback)
+ {
+ sendRequest(RPC_SCOPE,
+ CREATE_PRESENTATION_RPUBS_SOURCE,
+ requestCallback);
+ }
+
+ @Override
public void presentationExecuteCode(
String code,
ServerRequestCallback<Void> requestCallback)
@@ -2948,6 +2958,7 @@ public void devtoolsLoadAllPath(
private static final String RPUBS_TERMINATE_UPLOAD = "terminate_rpubs_upload";
private static final String CREATE_STANDALONE_PRESENTATION = "create_standalone_presentation";
+ private static final String CREATE_PRESENTATION_RPUBS_SOURCE = "create_presentation_rpubs_source";
private static final String SET_PRESENTATION_SLIDE_INDEX = "set_presentation_slide_index";
private static final String PRESENTATION_EXECUTE_CODE = "presentation_execute_code";
private static final String CLOSE_PRESENTATION_PANE = "close_presentation_pane";
View
59 src/gwt/src/org/rstudio/studio/client/workbench/views/presentation/Presentation.java
@@ -65,6 +65,7 @@
import org.rstudio.studio.client.workbench.views.presentation.events.ShowPresentationPaneEvent;
import org.rstudio.studio.client.workbench.views.presentation.events.SourceFileSaveCompletedEvent;
import org.rstudio.studio.client.workbench.views.presentation.model.PresentationCommand;
+import org.rstudio.studio.client.workbench.views.presentation.model.PresentationRPubsSource;
import org.rstudio.studio.client.workbench.views.presentation.model.PresentationServerOperations;
import org.rstudio.studio.client.workbench.views.presentation.model.PresentationState;
import org.rstudio.studio.client.workbench.views.presentation.model.SlideNavigationItem;
@@ -312,12 +313,7 @@ public void onResponseReceived(String savedFile)
@Override
public void onError(ServerError error)
{
- String message = error.getUserMessage();
- JSONString userMessage = error.getClientInfo().isString();
- if (userMessage != null)
- message = userMessage.stringValue();
-
- indicator.onError(message);
+ indicator.onError(getErrorMessage(error));
}
});
}
@@ -325,27 +321,26 @@ public void onError(ServerError error)
@Handler
void onPresentationPublishToRpubs()
{
- saveAsStandalone(null,
- new NullProgressIndicator(),
- new CommandWithArg<String>() {
- @Override
- public void execute(final String targetFile)
- {
- server_.rpubsIsPublished(targetFile,
- new SimpleRequestCallback<Boolean>() {
- @Override
- public void onResponseReceived(Boolean isPublished)
- {
- RPubsUploadDialog dlg = new RPubsUploadDialog(
- "Presentation",
- view_.getPresentationTitle(),
- targetFile,
- isPublished);
- dlg.showModal();
- }
-
- });
- }
+ server_.createPresentationRPubsSource(
+ new SimpleRequestCallback<PresentationRPubsSource>() {
+
+ @Override
+ public void onResponseReceived(PresentationRPubsSource source)
+ {
+ RPubsUploadDialog dlg = new RPubsUploadDialog(
+ "Presentation",
+ view_.getPresentationTitle(),
+ source.getSourceFilePath(),
+ source.isPublished());
+ dlg.showModal();
+ }
+
+ @Override
+ public void onError(ServerError error)
+ {
+ globalDisplay_.showErrorMessage("Error Saving Presentation",
+ getErrorMessage(error));
+ }
});
}
@@ -709,6 +704,16 @@ private static int detectSlideIndex(String contents, int cursorLine)
return -1;
}
+
+ private String getErrorMessage(ServerError error)
+ {
+ String message = error.getUserMessage();
+ JSONString userMessage = error.getClientInfo().isString();
+ if (userMessage != null)
+ message = userMessage.stringValue();
+ return message;
+ }
+
private final Display view_ ;
private final PresentationServerOperations server_;
private final GlobalDisplay globalDisplay_;
View
32 src/gwt/src/org/rstudio/studio/client/workbench/views/presentation/model/PresentationRPubsSource.java
@@ -0,0 +1,32 @@
+/*
+ * PresentationRPubsSource.java
+ *
+ * Copyright (C) 2009-12 by RStudio, Inc.
+ *
+ * Unless you have received this program directly from RStudio pursuant
+ * to the terms of a commercial license agreement with RStudio, then
+ * this program is licensed to you under the terms of version 3 of the
+ * GNU Affero General Public License. This program is distributed WITHOUT
+ * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
+ * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
+ *
+ */
+package org.rstudio.studio.client.workbench.views.presentation.model;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+public class PresentationRPubsSource extends JavaScriptObject
+{
+ protected PresentationRPubsSource()
+ {
+ }
+
+ public final native boolean isPublished() /*-{
+ return this.published;
+ }-*/;
+
+ public final native String getSourceFilePath() /*-{
+ return this.source_file_path;
+ }-*/;
+}
View
3  src/gwt/src/org/rstudio/studio/client/workbench/views/presentation/model/PresentationServerOperations.java
@@ -28,6 +28,9 @@ void createStandalonePresentation(
String targetFile,
ServerRequestCallback<String> requestCallback);
+ void createPresentationRPubsSource(
+ ServerRequestCallback<PresentationRPubsSource> requestCallback);
+
void setPresentationSlideIndex(int index,
ServerRequestCallback<Void> requestCallback);
Please sign in to comment.
Something went wrong with that request. Please try again.