Exemplo n.º 1
0
        public Task <string> RenderViewAsync(SkinTawkToModule module, SkinTawkToModuleController.DisplayModel model)
        {
            ScriptBuilder sb = new ScriptBuilder();

            ConfigData config = ConfigDataProvider.GetConfigAsync().Result;

            sb.Append($@"
// https://www.tawk.to/javascript-api/
var Tawk_API = Tawk_API || {{}}, Tawk_LoadStart = new Date();");

            if (Manager.HaveUser)
            {
                sb.Append($@"
Tawk_API.visitor = {{
    name: '{JE(Manager.UserName)}',
    email: '{JE(Manager.UserEmail)}',
    hash: '{JE(model.Hash)}'
}};");
            }

            sb.Append($@"
(function() {{
    var s1=document.createElement('script'),s0=document.getElementsByTagName('script')[0];
    s1.async=true;
    s1.src = '{JE(string.Format("https://embed.tawk.to/{0}/default", Utility.UrlEncodePath(config.Account)))}';
    s1.charset='UTF-8';
    s1.setAttribute('crossorigin','*');
    s0.parentNode.insertBefore(s1,s0);
}})();");

            Manager.ScriptManager.AddLast(sb.ToString());

            return(Task.FromResult <string>(null));
        }
Exemplo n.º 2
0
        public async Task AddSupportAsync(YetaWFManager manager)
        {
            ScriptManager scripts = manager.ScriptManager;
            string        area    = AreaRegistration.CurrentPackage.AreaName;

            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            scripts.AddConfigOption(area, "ExcludedPagesCss", config.ExcludedPagesCss);
            scripts.AddConfigOption(area, "IncludedPagesCss", config.IncludedPagesCss);
        }
Exemplo n.º 3
0
        public async Task <ActionResult> SharingSidebar()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            if (string.IsNullOrWhiteSpace(config.Code))
            {
                return(new EmptyResult());
            }
            DisplayModel model = new DisplayModel()
            {
                Code = config.Code,
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> SkinHighlightJS()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            // find theme specific skin
            Package    package    = AreaRegistration.CurrentPackage;
            SkinAccess skinAccess = new SkinAccess();
            string     theme      = skinAccess.FindHighlightJSSkin(config.HighlightJSSkin);
            await Manager.AddOnManager.AddAddOnNamedAsync(package.AreaName, "SkinHighlightJS", theme);

            // add client-side init
            Manager.ScriptManager.AddLast("YetaWF_SyntaxHighlighter_HighlightJS", "YetaWF_SyntaxHighlighter.HighlightJS.init();");

            return(new EmptyResult());
        }
Exemplo n.º 5
0
        public async Task <ActionResult> SkinSyntaxHighlighter()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            // find theme specific skin
            Package    package    = AreaRegistration.CurrentPackage;
            SkinAccess skinAccess = new SkinAccess();
            string     theme      = skinAccess.FindSyntaxHighlighterSkin(config.SyntaxHighlighterSkin);
            await Manager.AddOnManager.AddAddOnNamedAsync(package.AreaName, "SkinSyntaxHighlighter", theme);

            // add client-side init
            string url = VersionManager.GetAddOnNamedUrl(package.AreaName, "SkinSyntaxHighlighter");

            Manager.ScriptManager.AddLast("AlexGorbatchevCom_SyntaxHighlighter", "YetaWF_SyntaxHighlighter.AlexGorbatchevCom.init('" + url + "');");

            return(new EmptyResult());
        }
Exemplo n.º 6
0
        public async Task <ActionResult> SkinTawkTo()
        {
            ConfigData config = await ConfigDataProvider.GetConfigAsync();

            if (Manager.EditMode || !config.IsConfigured)
            {
                return(new EmptyResult());
            }
            DisplayModel model = new DisplayModel();

            if (Manager.HaveUser)
            {
                byte[] key = System.Text.Encoding.UTF8.GetBytes(config.APIKey);
                using (var hmacsha256 = new System.Security.Cryptography.HMACSHA256(key)) {
                    model.Hash = ByteArrayToString(hmacsha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes(Manager.UserEmail)));
                }
            }

            return(View(model));
        }
Exemplo n.º 7
0
        public async Task RunItemAsync(SchedulerItemBase evnt)
        {
            if (evnt.EventName == EventCreateBackup)
            {
                SiteBackup    siteBackup = new SiteBackup();
                List <string> errorList  = new List <string>();
                ConfigData    config     = await ConfigDataProvider.GetConfigAsync();

                await siteBackup.CreateAsync(errorList, DataOnly : config.DataOnly);
            }
            else if (evnt.EventName == EventRemoveOldBackups)
            {
                SiteBackup    siteBackup = new SiteBackup();
                List <string> errorList  = new List <string>();
                ConfigData    config     = await ConfigDataProvider.GetConfigAsync();

                await siteBackup.RemoveOldBackupsAsync(errorList, config.Days);
            }
            else
            {
                throw new Error(this.__ResStr("eventNameErr", "Unknown scheduler event {0}"), evnt.EventName);
            }
        }