public void ShowUrl(string sourceUrl, string gmiFile, string htmlFile, string themePath, SiteIdentity siteIdentity)
        {
            var hash = HashService.GetMd5Hash(sourceUrl);

            var usedShowWebHeaderInfo = false;

            var uri = new UriBuilder(sourceUrl);

            //only show web header for self generated content, not proxied
            usedShowWebHeaderInfo = uri.Scheme.StartsWith("http") && _settings.HandleWebLinks != "Gemini HTTP proxy";

            //create the html file
            ConverterService.CreateDirectoriesIfNeeded(gmiFile, htmlFile, themePath);
            var result = ConverterService.GmiToHtml(gmiFile, htmlFile, sourceUrl, siteIdentity, themePath, usedShowWebHeaderInfo);

            if (!File.Exists(htmlFile))
            {
                ToastNotify("GMIToHTML did not create content for " + sourceUrl + "\n\nFile: " + gmiFile, ToastMessageStyles.Error);

                ToggleContainerControlsForBrowser(true);
            }
            else
            {
                _urlsByHash[hash] = sourceUrl;

                //instead tell the browser to load the content
                Navigate(@"file:///" + htmlFile);
            }
        }
        public IActionResult Register(RegisterUserViewModel registerUserViewModel)
        {
            if (ModelState.IsValid)
            {
                if (context.Users.Where(x => x.Username.ToLower() == registerUserViewModel.Username.ToLower()).SingleOrDefault() == null)
                {
                    string hash = HashService.GetMd5Hash(md5Hash, registerUserViewModel.Password);

                    User newUser = RegisterUserViewModel.CreateUser(
                        registerUserViewModel.Username,
                        registerUserViewModel.Email,
                        hash);

                    context.Users.Add(newUser);
                    context.SaveChanges();

                    TempData["user"]   = JsonConvert.SerializeObject(newUser);
                    ViewBag.UserExists = "";

                    return(Redirect("/"));
                }
                else
                {
                    ViewBag.UserExists = "This username is already taken.";
                }
            }
            return(View(registerUserViewModel));
        }
Beispiel #3
0
        public string GetToNodeId()
        {
            if (!string.IsNullOrEmpty(_toNodeId))
            {
                return(_toNodeId);
            }

            var idString = GraphType.ToString();

            if (InterfaceType != null)
            {
                idString += ":" + AppDomain + ":" + InterfaceType.AssemblyName + ":" + InterfaceType.AssemblyVersion + ":" + InterfaceType.TypeName + ":" + MethodName;
            }
            else if (AbstractType != null)
            {
                idString += ":" + AppDomain + ":" + AbstractType.AssemblyName + ":" + AbstractType.AssemblyVersion + ":" + AbstractType.TypeName + ":" + MethodName;
            }
            else if (ConcreteType != null)
            {
                idString += ":" + AppDomain + ":" + ConcreteType.AssemblyName + ":" + ConcreteType.AssemblyVersion + ":" + ConcreteType.TypeName + ":" + MethodName;
            }
            else
            {
                throw new Exception("Id cannot be generated as no types exist. Method is " + MethodName);
            }

            _toNodeId = HashService.GetMd5Hash(idString);

            return(_toNodeId);
        }
        public void ShowImage(string sourceUrl, string imgFile)
        {
            var hash = HashService.GetMd5Hash(sourceUrl);

            _urlsByHash[hash] = sourceUrl;

            //instead tell the browser to load the content
            Navigate(@"file:///" + imgFile);
        }
Beispiel #5
0
        public void ShowImage(string sourceUrl, string imgFile, NavigatingCancelEventArgs e)
        {
            var hash = HashService.GetMd5Hash(sourceUrl);

            _urlsByHash[hash] = sourceUrl;

            //no further navigation right now
            e.Cancel = true;

            //instead tell the browser to load the content
            BrowserControl.Navigate(@"file:///" + imgFile);
        }
        private void MenuViewSource_Click(object sender, RoutedEventArgs e)
        {
            var    menu = (MenuItem)sender;
            string hash;

            //use the current session folder
            var sessionPath = Session.Instance.SessionPath;

            hash = HashService.GetMd5Hash(txtUrl.Text);

            //uses .txt as extension so content loaded as text/plain not interpreted by the browser
            var gmiFile = sessionPath + "\\" + hash + ".txt";

            Navigate(gmiFile);
        }