public PartialViewResult FullFeed(string widgetName, Include include)
 {
   var i = new FeedInclude(include);
   if (!i.Count.HasValue) i.Count = int.MaxValue;
   FeedModel model = new FeedModel() { Feed = GetFeed(i, false) };
   return PartialView(widgetName, model);
 }
 public PartialViewResult SizeAnnotations(string widgetName, Include include)
 {
   var i = new FeedInclude(include);
   if (!i.Count.HasValue) i.Count = 6;
   FeedModel model = new FeedModel() { Feed = GetFeed(i, true) };
   return PartialView(widgetName, model);
 }
 public override void Render(ViewContext ctx, Include include)
 {
   TagBuilder b = new TagBuilder("a");
   b.Attributes.Add("href",  GetLinkHref(ctx, include));
   b.Attributes.Add("rel", "config");
   b.SetInnerText("configure");
   ctx.HttpContext.Response.Write(b.ToString() + " | ");
 }
        public ActionResult ThemeWidget(Include Include)
        {
            var ThemeInclude = new ThemeInclude(Include);

            var theme = ThemeSwitcherService.GetThemeModel(ThemeInclude.ThemeName);

            return PartialView("ThemeWidget", theme);
        }
        public ActionResult Widget(Include include)
        {
            var gaInclude = new GA4AtomSiteInclude(include);

            if (string.IsNullOrEmpty(gaInclude.GoogleAccountID))
                return new EmptyResult();

            return PartialView("GA4AtomSiteWidget", new GA4AtomSiteModel { GoogleAccountID = gaInclude.GoogleAccountID });
        }
    public override void UpdatePageModel(PageModel pageModel, Include include)
    {
      //TODO: don't hardcode path to default theme
      string tailscript = File.ReadAllText(
        HostingEnvironment.MapPath("~/js/default/OpenIdModalWidgetTail.js"));
      pageModel.AddToTailScript(tailscript);

      base.UpdatePageModel(pageModel, include);
    }
        public ActionResult Widget(Include include)
        {
            if (Session["HideSwitcher"] != null)
                return new EmptyResult();
            ThemeSwitcherViewModel model = ThemeSwitcherService.GetModel(HttpContext, this.Scope);

            if (TempData.ContainsKey("ThemeSwitcherError"))
            {
                model.Message = TempData["ThemeSwitcherError"].ToString();
                model.IsMessageError = true;
            }

            return PartialView("ThemeSwitcherWidget", model);
        }
 public ActionResult Widget(Include include)
 {
   TwitterTimeline timeline = new TwitterTimeline();
   var i = new TwitterInclude(include);
   try
   {
     timeline = TwitterService.GetTimeline(i.Username, i.Count);
   }
   catch (Exception ex)
   {
     LogService.Error(ex);
   }
   return PartialView("TwitterWidget", timeline);
 }
 public PartialViewResult Entry(string widgetName, Include include)
 {
   var i = new IdInclude(include);
   Id entryId = EntryId;
   if (i.Id != null) entryId = i.Id;
   if (entryId == null) throw new ArgumentException("Unable to determine entry based on include or context.");
   EntryModel model = new EntryModel();
   try
   {
     model.Entry = AtomPubService.GetEntry(entryId);
   }
   catch (ResourceNotFoundException ex)
   {
     LogService.Error(ex);
   }
   return PartialView(widgetName, model);
 }
    //TODO: add caching?
    public ActionResult CustomWidget(Include include)
    {
      MenuModel model = new MenuModel();
      var menuItems = new MenuCustomInclude(include).MenuItems.Select(mi => new MenuItem()
      {
        Href = mi.Href,
        Title = mi.Title,
        Text = mi.Text,
        ExactSelect = mi.ExactSelect
      }).ToList();

      if (menuItems.Count() < 1) throw new ArgumentException("Include is missing custom menu items.");

      // mark selected, first pass do exact
      bool exact = false;
      foreach (MenuItem item in menuItems.Where(mi => mi.ExactSelect))
      {
        bool selected = item.Href.Substring(item.Href.IndexOf('/')) == Request.Url.PathAndQuery;
        if (selected)
        {
          item.Selected = true;
          exact = true;
          break;
        }
      }

      // no exact match, do fuzzy match
      if (!exact)
      {
        foreach (MenuItem item in menuItems.Where(mi => !mi.ExactSelect))
        {
          int lastSlash = item.Href.LastIndexOf('/');
          if (lastSlash < 1) lastSlash = item.Href.Length - 1;
          string areaPath = item.Href.Substring(0, lastSlash).Split('.').First().ToLower();
          item.Selected = Request.Url.PathAndQuery.ToLower().StartsWith(areaPath);
        }
      }

      foreach (MenuItem item in menuItems) model.MenuItems.Add(item);
      EnforceMaxSelection(model.MenuItems);
      return PartialView("MenuWidget", model);
    }
 protected virtual string GetLinkHref(ViewContext ctx, Include include)
 {
   var i = new ConfigLinkInclude(include);
   return new UrlHelper(ctx.RequestContext).Action(i.Action, i.Controller, new { includePath = i.IncludePath });
 }
 public LiteralInclude(Include include) : base(include) { }
 public IdInclude(Include include) : base(include) { }
 public ThemeInclude(Include include)
     : base(include.Xml) { }
    public ActionResult ContactWidget(Include include)
    {
      ContactModel model = new ContactModel();

      XElement contactElement = Workspace.Xml.Element(Contact.ContactXName);
      if (contactElement == null)
      {
        LogService.Warn("Contact settings are missing from the workspace. Please configure.");
      }

      model.TargetId = EntryId.ToString();
      return PartialView("ContactWidget", model);
    }
 public MenuCustomInclude(Include include)
   : base(include.Xml)
 { }
 public override bool IsEnabled(BaseModel baseModel, Include include)
 {
   BlogAppCollection c = new BlogAppCollection(baseModel.Collection);
   return (c.AnnotationsOn && c.BloggingOn &&
     baseModel.AuthorizeService.IsAuthorized(baseModel.User, baseModel.Scope, AuthAction.Annotate));
 }
 public ConfigInclude(Include include) : this(include.Xml) { }
 public Include(Include i) : base(i.Xml) { }
 public override void UpdatePageModel(PageModel pageModel, Include include)
 {
   pageModel.AddToTailScript("$(function() {$('.canrate').rater({ postHref: $('.canrate form').attr('action') });});");
   base.UpdatePageModel(pageModel, include);
 }
 public override bool IsEnabled(BaseModel baseModel, Include include)
 {
   return baseModel.Collection.AnnotationsOn;
 }
 public ScopeInclude(Include include) : base(include) { }
    public PartialViewResult SearchWidget(Include include)
    {
      string scope = new ScopeInclude(include).ScopeName ?? "workspace";
      string url = null;
      switch (scope)
      {
        case "site": url = Url.RouteUrlEx("BlogSearchService"); break;
        case "workspace": url = Url.RouteUrlEx("BlogSearchWorkspace", new { workspace = AppService.GetWorkspace().Name ?? Atom.DefaultWorkspaceName }); break;
        case "collection": url = Url.RouteIdUrl("BlogSearch", AppService.GetCollection().Id); break;
        default: throw new ArgumentException("The search scope is an unrecognized value.");
      }

      return PartialView("BlogSearchWidget",
        new BlogSearchModel() { SearchUrl = url });
    }
 public FeedConfigLinkInclude(Include include) : base(include) { }
 public GA4AtomSiteInclude(Include include)
     : base(include.Xml)
 {
 }
 protected override string GetLinkHref(ViewContext ctx, Include include)
 {
   var i = new FeedConfigLinkInclude(include);
   return new UrlHelper(ctx.RequestContext).Action(i.Action, i.Controller, new { includePath = i.IncludePath, hasTitle = i.HasTitle, hasCount = i.HasCount });
 }
 public override bool IsEnabled(BaseModel baseModel, Include include)
 {
   return new RaterAppCollection(baseModel.Collection).RatingsOn;
 }
 public ConfigLinkInclude(Include include) : base(include.Xml) { }
    private WidgetInclude GetInclude(bool inherited, string targetName, bool isPage, string areaName, int index, Include include, IList<IWidget> widgets, AdminWidgetsModel m)
    {
      var i = new WidgetInclude()
      {
        IncludePath = AppService.GetIncludePath(include),
        Name = include.Name,
        Inherited = inherited,
        RemoveHref = inherited ? null : Url.Action("RemoveInclude", new
        {
          workspace = Scope.Workspace,
          collection = Scope.Collection,
          targetType = isPage ? "page" : "widget",
          targetName = targetName,
          areaName = areaName,
          includeIdx = index
        }),
        MoveHref = inherited ? null : Url.Action("MoveInclude", new
        {
          workspace = Scope.Workspace,
          collection = Scope.Collection,
          targetType = isPage ? "page" : "widget",
          targetName = targetName,
          areaName = areaName,
          includeIdx = index
        }),
      };

      var widget = widgets.Where(w => w.Name == i.Name).FirstOrDefault();
      if (widget != null)
      {
        i.Desc = widget.Description;
        i.ScopeFlags = (int)widget.SupportedScopes;
        i.ConfigInclude = inherited ? null : widget.GetConfigInclude(i.IncludePath);
        i.Valid = widget.IsValid(include);
      }
      if (string.IsNullOrEmpty(i.Desc)) i.Desc = "Widget has no description.";
      return i;
    }
 public override bool IsEnabled(BaseModel baseModel, Include include)
 {
   BlogAppCollection c = new BlogAppCollection(baseModel.Collection);
   return (c.AnnotationsOn && c.BloggingOn);
 }