Exemplo n.º 1
0
    public void DownloadImageLocaly()
    {
        string name           = LoadAllImagesInProjectLocaly.RandomName();
        MarkdownImageAsText t = MarkdownImageAsText.CreateMarkdownImage(m_altText.text, m_image.text);

        StartCoroutine(LoadAllImagesInProjectLocaly.StartDownloadingImage(
                           t, name));
        t.SetUrlTo("Image/" + name + "." + t.GetFileExtension());
        SetText(t.GetText());
        StartCoroutine(StartDownloadPreview(m_image.text));
    }
    internal static void FindReplace(MarkdownImageInFile m_givenData, string newLocalUrl)
    {
        MarkdownImageAsText copy = m_givenData.markdownImage.Copy();

        copy.SetUrlTo(newLocalUrl);
        m_givenData.markdownFile.Load();
        string textOfFile = m_givenData.markdownFile.GetValue();

        textOfFile = textOfFile.Replace(m_givenData.markdownImage.GetText(), copy.GetText());
        File.WriteAllText(m_givenData.markdownFile.GetPath(), textOfFile);
        m_givenData.markdownFile.Unload();
    }
Exemplo n.º 3
0
    public void DownloadYoutubeLocaly()
    {
        string name       = LoadAllImagesInProjectLocaly.RandomName();
        string urlYoutube = GetYoutubeImageUrl();

        if (urlYoutube != "")
        {
            MarkdownImageAsText t = MarkdownImageAsText.CreateMarkdownImage(m_altText.text, urlYoutube);
            StartCoroutine(LoadAllImagesInProjectLocaly.StartDownloadingImage(
                               t, name));
            t.SetUrlTo("Image/" + name + "." + t.GetFileExtension());
            SetText(t.GetText());
            StartCoroutine(StartDownloadPreview(urlYoutube));
        }
    }
Exemplo n.º 4
0
    public static IEnumerator StartDownloadingImage(MarkdownImageAsText image, string name, bool asBackup = false)
    {
        //if (image.IsWebLink())
        {
            Debug.Log(">>>" + name + ": Download: " + image.GetImageLink().Trim());
            string path = image.GetImageLink();
            if (image.IsImagesFolder())
            {
                path = "file:///" + m_instance.m_gitProjetPath + "/" + path;
            }
            Debug.Log("lll:" + path);


            WWW download = new WWW(path);
            yield return(download);

            if (download != null || string.IsNullOrEmpty(download.error))
            {
                Debug.Log(">>>> Download fail: " + download.error);
            }

            {
                string pathToStore =
                    asBackup ? m_instance.m_gitProjetPath + "/" + m_instance.m_backupFolderName + "/":
                    m_instance.m_gitProjetPath + "/Image/";
                if (!Directory.Exists(pathToStore))
                {
                    Directory.CreateDirectory(pathToStore);
                }
                string foundExention = "";
                foundExention = image.GetFileExtension();
                if (foundExention != "")
                {
                    File.WriteAllBytes(pathToStore + name + "." + foundExention, download.bytes);
                }
                else
                {
                    File.WriteAllBytes(pathToStore + name + ".png", download.texture.EncodeToPNG());
                }

                Debug.Log(">>>> Downloaded: " + image.GetImageLink());
            }
        }
    }
Exemplo n.º 5
0
    private void CheckForMarkDownImage(string text)
    {
        m_imagesMarkdown = new List <MarkdownImageAsText>();
        m_imagesAsText   = new List <string>();

        MatchCollection collection = Regex.Matches(m_textInFile, m_imageMarkDownFormat);

        foreach (Match match in collection)
        {
            m_imagesAsText.Add(match.Value);
            try
            {
                MarkdownImageAsText md = new MarkdownImageAsText(match.Value);
                m_imagesMarkdown.Add(md);
                m_imageDetected.Invoke(md);
            }
            catch (Exception e)
            {
                Debug.LogWarning("Impossible to convert as image:" + match.Value);
            }
        }
    }
Exemplo n.º 6
0
 public MarkdownImageInFile(MarkdownFileWithText file, MarkdownImageAsText image)
 {
     this.markdownFile  = file;
     this.markdownImage = image;
 }