Example #1
0
        public static string GetImageInfoURL(string file_name)
        {
            WikiContent_Rootobject wikiobj = new WikiContent_Rootobject();

            string        scheme          = "https://";
            StringBuilder sb_ImageInfoURL = new StringBuilder(scheme);

            string language = "en";

            language = String.Format("{0}.", language);
            sb_ImageInfoURL.Append(language);

            string authority = "wikipedia.org";

            sb_ImageInfoURL.Append(authority);

            string api_path = "/w/api.php";

            sb_ImageInfoURL.Append(api_path);

            string action = "query";

            action = String.Format("?action={0}", action);
            sb_ImageInfoURL.Append(action);

            string titles = file_name;

            action = String.Format("&titles={0}", titles);
            sb_ImageInfoURL.Append(action);

            string prop = "imageinfo";

            prop = String.Format("&prop={0}", prop);
            sb_ImageInfoURL.Append(prop);

            string iiprop = "url|size|mediatype|canonicaltitle|parsedcomment";

            iiprop = String.Format("&iiprop={0}", iiprop);
            sb_ImageInfoURL.Append(iiprop);

            string iiurlwidth = "100"; //Not used now, to be later customized to call resized images. Req to get thumburl

            iiurlwidth = String.Format("&iiurlwidth={0}", iiurlwidth);
            sb_ImageInfoURL.Append(iiurlwidth);

            string format = "json";

            format = String.Format("&format={0}", format);
            sb_ImageInfoURL.Append(format);

            string formatversion = "2";

            formatversion = String.Format("&formatversion={0}", formatversion);
            sb_ImageInfoURL.Append(formatversion);


            string URL = sb_ImageInfoURL.ToString();

            return(URL);
        }
Example #2
0
 public bool Does_Node_HaveImageInfo(WikiContent_Rootobject wikicontent_rootobject, int N1_index)
 {
     if (wikicontent_rootobject.Node_1_list[N1_index].ParsedImage_list.Count == 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
 public bool Does_Intro_HaveImageInfo(WikiContent_Rootobject wikicontent_rootobject)
 {
     if (wikicontent_rootobject.Introduction.ParsedImage_list.Count == 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #4
0
        public async void SubmitButtonEvent()
        {
            progressRing.IsActive = true;

            WikiContent_Rootobject wikiContent       = new WikiContent_Rootobject();
            Rootobject             data_AsRootObject = await wikiContent.GetPageContent(searchQuery.Text);


            //Adds introduction information into variable
            Introduction introduction = new Introduction();
            Rootobject   intro        = await GetPageContent(searchQuery.Text, "0");

            string data_AsString = intro.query.pages[0].revisions[0].content;

            introduction.Content = data_AsString;                                                                        //Gets intro paragraph
            data_AsString        = wikiContent.Regex_DeleteData(data_AsString, @"(\n|^)'''(.|\n)*?(?=\n==(\w|\d))", ""); //Removes intro paragraph

            introduction.DataTable = wikiContent.GetIntroTablesAndData(data_AsString);                                   //Gets table data
            data_AsString          = wikiContent.Regex_DeleteData(data_AsString, @"^{{(.|\n)*?\n}}(?=\n''')", "");       //Removes table data



            //Gets intro images
            string intro_tables_and_content             = String.Format("{0}{1}", introduction.DataTable, introduction.Content);
            List <ParsedImageInfo> intro_imageinfo_list = new List <ParsedImageInfo>();

            intro_imageinfo_list = GetImageInfoFromContent(intro_tables_and_content);

            //Intro images
            int intro_imageinfo_count = intro_imageinfo_list.Count;

            for (int i = 0; i < intro_imageinfo_count; i++)
            {
                Rootobject rootobject_image = new Rootobject();
                string     parsedImageName  = ParseImageName(intro_imageinfo_list[i].Filename);
                string     imageinfoURL     = GetImageInfoURL(parsedImageName);
                rootobject_image = await GetImageInfoFromAPI(imageinfoURL);

                SetImageProperties(rootobject_image, intro_imageinfo_list, i);
            }

            wikiContent.Introduction = introduction;

            Rootobject rootobj = await GetPageSections(searchQuery.Text);


            wikiContent = await PutSectionsIntoNodes(rootobj);

            wikiContent.Introduction = introduction;
            wikiContent.PageTitle    = data_AsRootObject.parse.title;

            ForEachContentHolder contentholder = new ForEachContentHolder();


            //Textblock1.Text = contentholder.StringContent;

            //Teeing up info to pass to next page
            WikiPageContentsToPass PassThruContent = new WikiPageContentsToPass();

            wikiContent.RemainingContent = data_AsString;
            Frame.Navigate(typeof(ContentPage), wikiContent);
        }
Example #5
0
        public async Task <WikiContent_Rootobject> PutSectionsIntoNodes(Rootobject rootobject)
        {
            WikiContent_Rootobject wikiContent = new WikiContent_Rootobject();
            List <Node_1>          n1_list     = new List <Node_1>();

            wikiContent.Node_1_list = n1_list;

            List <Node_2> n2_list = new List <Node_2>();
            List <Node_3> n3_list = new List <Node_3>();
            List <Node_4> n4_list = new List <Node_4>();

            int n1 = -1;
            int n2 = -1;
            int n3 = -1;
            int n4 = 0;

            foreach (Section section in rootobject.parse.sections)
            {
                string section_title = section.anchor;
                string section_index = section.index;
                string section_num   = section.number;



                string input = section.number;

                //n1
                string pattern_n1 = @"^\d{1,3}$";
                Regex  regex_n1   = new Regex(pattern_n1);
                Match  m_n1       = regex_n1.Match(input);

                //n2
                string pattern_n2 = @"^\d{1,3}\.\d{1,3}$";
                Regex  regex_n2   = new Regex(pattern_n2);
                Match  m_n2       = regex_n2.Match(input);

                //n3
                string pattern_n3 = @"^\d{1,3}\.\d{1,3}\.\d{1,3}$";
                Regex  regex_n3   = new Regex(pattern_n3);
                Match  m_n3       = regex_n3.Match(input);

                //n4
                string pattern_n4 = @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$";
                Regex  regex_n4   = new Regex(pattern_n4);
                Match  m_n4       = regex_n1.Match(input);

                if (m_n1.Success)
                {
                    n2 = -1;
                    n3 = -1;
                    n4 = -1;
                    //Add everything added previously

                    Node_1        n1_iteration = new Node_1();
                    List <Node_2> n2list       = new List <Node_2>();

                    n1_iteration.Node_2_list = n2list;

                    n1_iteration.SectionTitle = section_title;
                    n1_iteration.SectionNum   = section_num;
                    n1_iteration.SectionIndex = section_index;

                    //string n1_and_derivative_content = rootobject.query.pages[0].revisions[0].content;
                    Rootobject n1_rootobject = await GetPageContent(searchQuery.Text, section_index);

                    string SectionContent = n1_rootobject.query.pages[0].revisions[0].content;

                    //And Saves value in N1
                    GetAllContent(SectionContent, n1_iteration);


                    wikiContent.Node_1_list.Add(n1_iteration);


                    //Now empty the node so we add the current val into it
                    Node_1 n1_empty = new Node_1();
                    n1_iteration = n1_empty;

                    n1++;
                }

                else
                {
                }
            }
            return(wikiContent);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            WikiContent_Rootobject parametersPassed = (WikiContent_Rootobject)e.Parameter;

            Frame.Navigate(typeof(ContentPage), parametersPassed);
        }