internal void InitializeContent(Page page)
 {
     if (Page != null) return;
     Page = page;
     TcmId = page.Id.ItemId;
     Title = page.Title;
     MajorVersion = page.Version;
     MinorVersion = page.Revision;
     OwningPublication = page.OwningRepository.Id.ItemId;
     CreationDate = page.CreationDate;
     ModificationDate = page.RevisionDate;
     PublicationId = page.ContextRepository.Id.ItemId;
     TemplateId = page.PageTemplate.Id.ItemId;
     OrganizationalItemId = page.OrganizationalItem.Id.ItemId;
     OrganizationalItemTitle = page.OrganizationalItem.Title;
     Url = page.PublishLocationUrl;
     ComponentPresentations = new List<SimpleComponentPresentation>();
     foreach (ComponentPresentation cp in page.ComponentPresentations)
     {
         ComponentPresentations.Add(new SimpleComponentPresentation{ComponentId = cp.Component.Id.ItemId, TemplateId = cp.ComponentTemplate.Id.ItemId});
     }
     if (page.ComponentPresentations.Count > 0)
     {
         Article a = new Article(page.ComponentPresentations[0].Component, Data );
         InformationSource = a.InformationSource.Title;
     }
     PublicationDate = DateTime.Now;
     TemplateModifiedDate = page.PageTemplate.RevisionDate;
 }
        public void Transform(Engine engine, Package package)
        {
            Component c = (Component) engine.GetObject(package.GetByName(Package.ComponentName));
            if (c.Schema.Title != "Article" || c.Schema.Title == "Label") return;
            Article article = new Article(c, engine);
            //string content = PluralizationService.CreateService(CultureInfo.CurrentCulture).Pluralize(c.Schema.Title) + Environment.NewLine;

            //string content = article.ToBsonDocument().ToJson(new JsonWriterSettings{OutputMode = JsonOutputMode.Strict});
            string content = JsonConvert.SerializeObject(article);

            package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, content));
        }
        public void Transform(Engine engine, Package package)
        {
            Page page = (Page)engine.GetObject(package.GetByName(Package.PageName));
            TcmUri articleSchemaUri = new TcmUri(Constants.SchemaArticleId, ItemType.Schema, page.Id.PublicationId);
            UsingItemsFilter filter = new UsingItemsFilter(engine.GetSession()) { ItemTypes = new[] { ItemType.Component } };
            Schema schema = (Schema)engine.GetObject(articleSchemaUri);

            TagCloud tagCloud = new TagCloud
                {
                    Tags = new List<Tag>(),
                    PublicationId = page.Id.PublicationId,
                    TcmId = page.Id.ItemId,
                    PageTitle = page.Title
                };

            SortedList<string, int> tags = new SortedList<string, int>(StringComparer.CurrentCultureIgnoreCase);

            foreach (Component c in schema.GetUsingItems(filter))
            {
                Article a = new Article(c, engine);
                string tag = a.Author.Name;
                if (tags.ContainsKey(tag))
                {
                    tags[tag] = tags[tag] + 1;
                }
                else
                {
                    tags.Add(tag, 1);
                }
            }

            foreach (var tag in tags)
            {
                tagCloud.Tags.Add(new Tag { TagName = tag.Key.ToAscii(), TagValue = tag.Value });
            }

            string content = JsonConvert.SerializeObject(tagCloud);
            //content += tagCloud.ToBsonDocument().ToJson(new JsonWriterSettings { OutputMode = JsonOutputMode.Strict });
            package.PushItem(Package.OutputName, package.CreateStringItem(ContentType.Text, content));
        }