コード例 #1
0
        public void RegisterWithApiHandler(BloomApiHandler apiHandler)
        {
            apiHandler.RegisterEndpointHandler(kAppUrlPrefix + "enabledExperimentalFeatures", request =>
            {
                if (request.HttpMethod == HttpMethods.Get)
                {
                    request.ReplyWithText(ExperimentalFeatures.TokensOfEnabledFeatures);
                }
                else                 // post
                {
                    System.Diagnostics.Debug.Fail("We shouldn't ever be using the 'post' version.");
                    request.PostSucceeded();
                }
            }, false);
            apiHandler.RegisterEndpointHandler(kAppUrlPrefix + "autoUpdateSoftwareChoice", HandleAutoUpdate, false);


            /* It's not totally clear if these kinds of things fit well in this App api, or if we
             * will want to introduce a separate api for dealing with these kinds of things. I'm
             * erring on the side of less classes, code, for now, easy to split later.*/
            apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "editSelectedBook",
                                              request =>
            {
                _editBookCommand.Raise(_bookSelection.CurrentSelection);
                request.PostSucceeded();
            }, true);
            apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "makeFromSelectedBook",
                                              request =>
            {
                // Original in LibraryBookView had this...not sure if we might want it again.
                //nb: don't move this to after the raise command, as the selection changes
                // var checkinNotice = string.Format("Created book from '{0}'", _bookSelection.CurrentSelection.TitleBestForUserDisplay);

                try
                {
                    _createFromSourceBookCommand.Raise(_bookSelection.CurrentSelection);
                }
                catch (Exception error)
                {
                    SIL.Reporting.ErrorReport.NotifyUserOfProblem(error,
                                                                  "Bloom could not add that book to the collection.");
                }

                request.PostSucceeded();
            }, true);
            apiHandler.RegisterEndpointLegacy(kAppUrlPrefix + "selectedBookInfo",
                                              request =>
            {
                // Requests the same information that is sent to the websocket
                // when the selection changes.
                request.ReplyWithJson(WorkspaceView.GetCurrentSelectedBookInfo());
            }, true);
        }
コード例 #2
0
        public void RegisterWithApiHandler(BloomApiHandler apiHandler)
        {
            apiHandler.RegisterEndpointLegacy("collection/defaultFont", request =>
            {
                var bookFontName = _bookSelection.CurrentSelection.BookData.Language1.FontName;
                if (String.IsNullOrEmpty(bookFontName))
                {
                    bookFontName = "sans-serif";
                }
                request.ReplyWithText(bookFontName);
            }, handleOnUiThread: false);

            apiHandler.RegisterEndpointLegacy("readers/ui/.*", HandleRequest, true);
            apiHandler.RegisterEndpointLegacy("readers/io/.*", HandleRequest, false);
            apiHandler.RegisterEndpointLegacy("directoryWatcher/", ProcessDirectoryWatcher, false);

            //we could do them all like this:
            //server.RegisterEndpointLegacy("readers/loadReaderToolSettings", r=> r.ReplyWithJson(GetDefaultReaderSettings(r.CurrentCollectionSettings)));
        }
コード例 #3
0
 public void RegisterWithApiHandler(BloomApiHandler apiHandler)
 {
     // Not sure this needs UI thread, but it can result in saving the page, which seems
     // safest to do that way.
     apiHandler.RegisterEndpointLegacy("book/settings", HandleBookSettings, true);
 }
コード例 #4
0
ファイル: I18NApi.cs プロジェクト: gmartin7/myBloomFork
 public void RegisterWithApiHandler(BloomApiHandler apiHandler)
 {
     // We get lots of these requests, and they don't use any non-local data except the LocalizationManager,
     // which is designed to be thread-safe for lookup functions. So we can take advantage of parallelism here.
     apiHandler.RegisterEndpointLegacy("i18n/", HandleI18nRequest, false, false);
 }