Exemple #1
0
 protected override void PostProcess(Message m)
 {
     var c = m.RawId.LastIndexOf(':');
     if (c > 0 && c < m.RawId.Length - 3) {
         //var id = m.RawId.Substring(c + 1);
         m.MediaUrl = "";//"http://www.youtube.com/get_video?fmt=18&video_id=" + id + "&t=";
         //Console.WriteLine (m.MediaUrl);
     }
 }
Exemple #2
0
        protected override void PostProcess(Message m)
        {
            var html = Html.Parse(m.BodyHtml);

            var imgs = html.SelectNodes("//img");
            if (imgs == null) return;

            var url = "";

            foreach (HtmlNode img in imgs) {
                var p = img.ParentNode;
                if (p == null) continue;
                if (p.Name != "a") continue;

                var href = p.Attributes["href"];
                if (href == null) continue;

                url = href.Value;
                if (url.StartsWith("http://picasaweb") && url.ToLowerInvariant().IndexOf(User.ToLowerInvariant()) > 0) {
                    break;
                }
            }
            if (url == "") return;

            var albumHtml = Http.Get(url);

            var ma = PhotosRssRe.Match(albumHtml);

            if (ma.Success) {

                var jsUrl = ma.Groups[1].Value;
                url = jsUrl.Replace("\\x2F", "/").Replace("\\x26", "&");

                var xml = XDocument.Parse(Http.Get(url));

                foreach (var item in xml.Descendants("item")) {
                    foreach (var c in item.Elements()) {
                        if (c.Name.LocalName == "group") {
                            foreach (var med in c.Elements()) {

                                if (med.Name.LocalName == "content") {

                                    var img = med.Attribute("url").Value;
                                    m.BodyHtml += "<br/><img src='" + img + "' />";
                                }

                            }
                        }
                    }
                }

            }
        }
Exemple #3
0
 protected override void PostProcess(Message m)
 {
     //m.BodyHtml = Html.GetCleanArticle(m.Url);
 }
Exemple #4
0
        protected override void PostProcess(Message m)
        {
            var root = Html.Get(m.Url);

            var userbody = root.SelectSingleNode("//div[@id='userbody']");

            if (userbody != null) {

                //
                // Remove the blurbs
                //
                var blurbs = userbody.SelectSingleNode("ul[@class='blurbs']");
                if (blurbs != null) {
                    userbody.RemoveChild(blurbs);
                }

                //
                // Move the pictures to the top
                //
                var images = userbody.SelectSingleNode("table[@summary='craigslist hosted images']");
                if (images != null) {
                    userbody.RemoveChild(images);
                    userbody.InsertBefore(images, userbody.FirstChild);
                }

                m.BodyHtml = userbody.InnerHtml;
            }
        }
Exemple #5
0
        void OnModelChanged()
        {
            //			Console.WriteLine ("READER ON MODEL CHANGED");

            var html = "";
            if (Message != null) {
                html = Message.BodyHtml;
            }

            _showingMessages = true;
            UpdateOriginalToggleUI ();

            TopBtn.Def.ComponentType = LcarsComponentType.MiscFunction;
            TopBtn.Def.IsCommandable = true;
            BottomBtn.Def.ComponentType = LcarsComponentType.MiscFunction;
            BottomBtn.Def.IsCommandable = true;

            TopBtn.SetNeedsDisplay ();
            BottomBtn.SetNeedsDisplay ();

            var eq = (_lastHtml == html && object.ReferenceEquals(Message, _lastMessage));
            if (!eq) {
                _lastHtml = html;
                _lastMessage = Message;

                var subj = "";
                var byline = "";
                if (Message != null) {
                    subj = Message.Subject;
                    byline = Message.From;
                    var tm = Message.PublishTime.ToLocalTime ();
                    byline += " " + tm.ToLongDateString ();
                    byline += " " + tm.ToShortTimeString ();
                }

                var head = "<div class='byline'>" + Html.Encode (byline) + "</div>";

                Source source = null;
                if (Message != null) {
                    source = Repo.Foreground.Resolve (Message.GetSourceReference ());
                }

                var showSubj = source.ShouldShowSubjectWithBody;
                var subjIsBody = false;
                if (Message != null && Message.BodyHtml == "&nbsp;") {
                    showSubj = false;
                    subjIsBody = true;
                }

                if (source != null && showSubj) {
                    head = "<h1>" + Html.Encode (subj) + "</h1>" + head;
                }

                var shtml = html;

                if (subjIsBody) {
                    shtml = Message.Subject;
                }

                if (ShouldSanitize (shtml)) {
                    shtml = Sanitize (shtml);
                }

                shtml = head + shtml;
                SetHtml (shtml, "");
            }
            TextBox.Hidden = string.IsNullOrEmpty (html);

            Info.ScreenTitle = Message.GetTextSummary ();

            KillMedia ();

            var isAudio = Message.MediaUrl.IndexOf (".mp3") > 0;

            if (Message.HasMedia) {

                PlayBtn.Def.IsCommandable = true;
                PlayBtn.Def.ComponentType = LcarsComponentType.SystemFunction;
                PlayBtn.Def.Caption = GetPlayCaption ();
                PlayBtn.Def.Command = delegate {
                    if (isAudio) {
                        if (_audioPlayer == null) {
                            _audioPlayer = AudioPlayerController.Get (Message.MediaUrl);
                            _audioPlayer.Play ();
                            _updatePlayTimer = NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromSeconds (1), delegate {
                                if (_audioPlayer != null) {
                                    PlayBtn.Def.Caption = _audioPlayer.GetStatus (false);
                                    PlayBtn.SetNeedsDisplay ();
                                }
                            });
                        } else {
                            if (_audioPlayer.IsPlaying) {
                                _audioPlayer.Pause ();
                            } else {
                                _audioPlayer.Play ();
                            }
                        }
                    } else {
                        App.Inst.ShowFullScreenVideo (Message.MediaUrl);
                    }
                    PlayBtn.SetNeedsDisplay ();
                };
            } else {
                PlayBtn.Def.IsCommandable = false;
                PlayBtn.Def.ComponentType = LcarsComponentType.Gray;
                PlayBtn.Def.Caption = "";
            }
            PlayBtn.SetNeedsDisplay ();

            App.Inst.RefreshInfo ();
        }
Exemple #6
0
 protected override void PostProcess(Message m)
 {
 }