Ejemplo n.º 1
0
 public void RegisterWithApiHandler(BloomApiHandler apiHandler)
 {
     apiHandler.RegisterEndpointHandler(kShowAdvancedFeaturesUrlPart, request =>
     {
         if (request.HttpMethod == HttpMethods.Get)
         {
             request.ReplyWithText(Settings.Default.ShowExperimentalFeatures.ToString().ToLowerInvariant());
         }
         else                 // post
         {
             NoPostAllowed(request);
         }
     }, false);
     apiHandler.RegisterEndpointHandler(kEnterpriseEnabledUrlPart, request =>
     {
         if (request.HttpMethod == HttpMethods.Get)
         {
             request.ReplyWithBoolean(IsEnterpriseEnabled);
         }
         else                 // post
         {
             NoPostAllowed(request);
         }
     }, true);
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void RegisterWithApiHandler(BloomApiHandler apiHandler)
        {
            apiHandler.RegisterEndpointHandler("collection/defaultFont", request =>
            {
                var bookFontName = request.CurrentCollectionSettings.Language1.FontName;
                if (String.IsNullOrEmpty(bookFontName))
                {
                    bookFontName = "sans-serif";
                }
                request.ReplyWithText(bookFontName);
            }, handleOnUiThread: false);

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

            //we could do them all like this:
            //server.RegisterEndpointHandler("readers/loadReaderToolSettings", r=> r.ReplyWithJson(GetDefaultReaderSettings(r.CurrentCollectionSettings)));
        }
Ejemplo n.º 4
0
 public void RegisterWithApiHandler(BloomApiHandler apiHandler)
 {
     apiHandler.RegisterEndpointHandler("i18n/", HandleI18nRequest, false);
 }
Ejemplo n.º 5
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.RegisterEndpointHandler("book/settings", HandleBookSettings, true);
 }