How to use @paperbits/core - 9 common examples

To help you get started, we’ve selected a few @paperbits/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / api-management-developer-portal / src / startup.publish.ts View on Github external
import { ProseMirrorModule } from "@paperbits/prosemirror/prosemirror.module";
import { StaticSettingsProvider } from "./components/staticSettingsProvider";
import { FileSystemBlobStorage } from "./components/filesystemBlobStorage";
import { ApimPublishModule } from "./apim.publish.module";

/* Reading settings from configuration file */
const configFile = path.resolve(__dirname, "./config.json");
const configuration = JSON.parse(fs.readFileSync(configFile, "utf8").toString());
const settingsProvider = new StaticSettingsProvider(configuration);

/* Storage where the website get published */
const outputBlobStorage = new FileSystemBlobStorage("./dist/website");

/* Initializing dependency injection container */
const injector = new InversifyInjector();
injector.bindModule(new CoreModule());
injector.bindModule(new CorePublishModule());
injector.bindModule(new StyleModule());
injector.bindModule(new ProseMirrorModule());
injector.bindModule(new ApimPublishModule());
injector.bindInstance("settingsProvider", settingsProvider);
injector.bindInstance("outputBlobStorage", outputBlobStorage);
injector.resolve("autostart");

/* Allowing self-signed certificates for HTTP requests */
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";

/* Bulding dependency injection container */
const publisher = injector.resolve("sitePublisher");

/* Running actual publishing */
publisher.publish()
github Azure / api-management-developer-portal / examples / function / publish / index.ts View on Github external
managementApiAccessToken: configuration.managementApiAccessToken,
        blobStorageContainer: configuration.outputBlobStorageContainer,
        blobStorageConnectionString: configuration.outputBlobStorageConnectionString,
        environment: "publishing"
    });

    const outputSettingsProvider = new StaticSettingsProvider({
        blobStorageContainer: configuration.outputBlobStorageContainer,
        blobStorageConnectionString: configuration.outputBlobStorageConnectionString
    });

    /* Storage where the website get published */
    const outputBlobStorage = new AzureBlobStorage(outputSettingsProvider);

    const injector = new InversifyInjector();
    injector.bindModule(new CoreModule());
    injector.bindModule(new CorePublishModule());
    injector.bindModule(new StyleModule());
    injector.bindModule(new ProseMirrorModule());
    injector.bindModule(new ApimPublishModule());
    injector.bindInstance("settingsProvider", settingsProvider);
    injector.bindInstance("outputBlobStorage", outputBlobStorage);
    injector.resolve("autostart");

    const publisher = injector.resolve("sitePublisher");
    await publisher.publish();
}
github Azure / api-management-developer-portal / examples / function / publish / index.ts View on Github external
blobStorageContainer: configuration.outputBlobStorageContainer,
        blobStorageConnectionString: configuration.outputBlobStorageConnectionString,
        environment: "publishing"
    });

    const outputSettingsProvider = new StaticSettingsProvider({
        blobStorageContainer: configuration.outputBlobStorageContainer,
        blobStorageConnectionString: configuration.outputBlobStorageConnectionString
    });

    /* Storage where the website get published */
    const outputBlobStorage = new AzureBlobStorage(outputSettingsProvider);

    const injector = new InversifyInjector();
    injector.bindModule(new CoreModule());
    injector.bindModule(new CorePublishModule());
    injector.bindModule(new StyleModule());
    injector.bindModule(new ProseMirrorModule());
    injector.bindModule(new ApimPublishModule());
    injector.bindInstance("settingsProvider", settingsProvider);
    injector.bindInstance("outputBlobStorage", outputBlobStorage);
    injector.resolve("autostart");

    const publisher = injector.resolve("sitePublisher");
    await publisher.publish();
}
github Azure / api-management-developer-portal / src / startup.publish.ts View on Github external
import { StaticSettingsProvider } from "./components/staticSettingsProvider";
import { FileSystemBlobStorage } from "./components/filesystemBlobStorage";
import { ApimPublishModule } from "./apim.publish.module";

/* Reading settings from configuration file */
const configFile = path.resolve(__dirname, "./config.json");
const configuration = JSON.parse(fs.readFileSync(configFile, "utf8").toString());
const settingsProvider = new StaticSettingsProvider(configuration);

/* Storage where the website get published */
const outputBlobStorage = new FileSystemBlobStorage("./dist/website");

/* Initializing dependency injection container */
const injector = new InversifyInjector();
injector.bindModule(new CoreModule());
injector.bindModule(new CorePublishModule());
injector.bindModule(new StyleModule());
injector.bindModule(new ProseMirrorModule());
injector.bindModule(new ApimPublishModule());
injector.bindInstance("settingsProvider", settingsProvider);
injector.bindInstance("outputBlobStorage", outputBlobStorage);
injector.resolve("autostart");

/* Allowing self-signed certificates for HTTP requests */
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";

/* Bulding dependency injection container */
const publisher = injector.resolve("sitePublisher");

/* Running actual publishing */
publisher.publish()
    .then(() => {
github Azure / api-management-developer-portal / src / startup.design.ts View on Github external
import "./polyfills";
import * as ko from "knockout";
import { InversifyInjector } from "@paperbits/common/injection";
import { CoreDesignModule } from "@paperbits/core/core.design.module";
import { StylesDesignModule } from "@paperbits/styles/styles.design.module";
import { ProseMirrorModule } from "@paperbits/prosemirror/prosemirror.module";
import { OfflineModule } from "@paperbits/common/persistence/offline.module";
import { ApimDesignModule } from "./apim.design.module";


/* Initializing dependency injection container */
const injector = new InversifyInjector();
injector.bindModule(new CoreDesignModule());
injector.bindModule(new StylesDesignModule());
injector.bindModule(new ProseMirrorModule());
injector.bindModule(new ApimDesignModule());
injector.bindModule(new OfflineModule({ autosave: false }));
injector.resolve("autostart");

/* Bootstrapping the application */
document.addEventListener("DOMContentLoaded", () => {
    setImmediate(() => ko.applyBindings(undefined, document.body));
});
github Azure / api-management-developer-portal / src / publishing / pagePublisher.ts View on Github external
private async renderPage(page: PageContract, settings: SettingsContract, iconMedia: MediaContract, imageMedia: MediaContract): Promise<{ permalink, bytes }> {
        console.log(`Publishing page ${page.title}...`);

        const templateDocument = createDocument(template);

        let permalink = page.permalink;
        let htmlContent: string;

        const buildContentPromise = new Promise(async (resolve, reject) => {
            const layoutViewModel = await this.layoutViewModelBinder.getLayoutViewModel(page.permalink, null);
            ko.applyBindingsToNode(templateDocument.body, { widget: layoutViewModel }, null);

            if (page.ogImageSourceKey) {
                imageMedia = await this.mediaService.getMediaByKey(page.ogImageSourceKey);
            }

            this.setSiteSettings(templateDocument, settings, iconMedia, imageMedia, page, page.permalink);

            setTimeout(() => {
                htmlContent = "" + templateDocument.documentElement.outerHTML;
github Azure / api-management-developer-portal / src / publishing / blogPublisher.ts View on Github external
private async renderBlogPost(post: BlogPostContract, settings: SettingsContract, iconFile: MediaContract): Promise<{ name, bytes }> {
        console.log(`Publishing blog post ${post.title}...`);
        const templateDocument = createDocument(template);

        let resourceUri: string;
        let htmlContent: string;

        const buildContentPromise = new Promise(async (resolve, reject) => {
            const layoutViewModel = await this.layoutViewModelBinder.getLayoutViewModel(post.permalink, null);
            ko.applyBindingsToNode(templateDocument.body, { widget: layoutViewModel }, null);

            setTimeout(() => {
                this.setSiteSettings(templateDocument, settings, iconFile, post);
                htmlContent = "" + templateDocument.documentElement.outerHTML;
                resolve();
            }, 500);
        });

        await buildContentPromise;
github Azure / api-management-developer-portal / src / publishing / publishing.module.ts View on Github external
public register(injector: IInjector): void {
        createDocument();
        
        injector.bindSingleton("sitePublisher", SitePublisher);
        injector.bindSingleton("assetPublisher", AssetPublisher);
        injector.bindSingleton("pagePublisher", PagePublisher);
        injector.bindSingleton("mediaPublisher", MediaPublisher);

        const stylePublisher = injector.resolve("stylePublisher");
        const pagePublisher = injector.resolve("pagePublisher");
        const mediaPublisher = injector.resolve("mediaPublisher");
        const assetPublisher = injector.resolve("assetPublisher");

        injector.bindInstance("publishers", [
            stylePublisher,
            assetPublisher,
            mediaPublisher,
            pagePublisher
github Azure / api-management-developer-portal / src / apim.runtime.module.ts View on Github external
public register(injector: IInjector): void {
        injector.bindModule(new KnockoutRegistrationLoaders());
        injector.bindSingleton("eventManager", DefaultEventManager);
        injector.bindSingleton("logger", ConsoleLogger);
        injector.bindCollection("autostart");
        injector.bindToCollection("autostart", UnhandledErrorHandler);
        injector.bindCollection("routeGuards");
        injector.bindToCollection("routeGuards", SignOutRouteGuard);
        injector.bindToCollection("autostart", VisibilityGuard);
        injector.bindSingleton("router", DefaultRouter);
        injector.bind("apiList", ApiList);
        injector.bind("apiListDropdown", ApiListDropdown);
        injector.bind("apiListTiles", ApiListTiles);
        injector.bind("apiDetails", ApiDetails);
        injector.bind("apiHistory", ApiHistory);
        injector.bind("operationDetails", OperationDetails);
        injector.bind("operationConsole", OperationConsole);
        injector.bind("typeDefinition", TypeDefinitionViewModel);