Esempio n. 1
0
        string IMetaWeblog.AddPost(string blogid, string username, string password, MetaWeblogPost post, bool publish)
        {
            var user = ValidateUser(username, password);

            var root = BlogRoot();

            var node = root.ChildrenOfType(ArticulateConstants.ArticulateArchiveContentTypeAlias).FirstOrDefault();

            if (node == null)
            {
                throw new XmlRpcFaultException(0, "No Articulate Archive node found");
            }

            var contentType = _contentTypeService.Get("ArticulateRichText");

            if (contentType == null)
            {
                throw new InvalidOperationException("No content type found with alias 'ArticulateRichText'");
            }

            var content = _contentService.CreateWithInvariantOrDefaultCultureName(
                post.Title, node.Id, contentType, _localizationService, user.Id);

            var extractFirstImageAsProperty = false;

            if (root.HasProperty("extractFirstImage"))
            {
                extractFirstImageAsProperty = root.Value <bool>("extractFirstImage");
            }

            AddOrUpdateContent(content, contentType, post, user, publish, extractFirstImageAsProperty);

            return(content.Id.ToString(CultureInfo.InvariantCulture));
        }
Esempio n. 2
0
        private IContent InstallContentData()
        {
            InstallMedia();

            var articulateType = _contentTypeService.Get("Articulate");

            if (articulateType == null)
            {
                _logger.Warn <ArticulateDataInstaller>("No 'Articulate' content type found");
                return(null);
            }

            //Create the root node - this will automatically create the authors and archive nodes
            _logger.Info <ArticulateDataInstaller>("Creating Articulate root node");
            var root = _contentService.CreateWithInvariantOrDefaultCultureName("Blog", Constants.System.Root, articulateType, _localizationService);

            root.SetInvariantOrDefaultCultureValue("theme", "VAPOR", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("pageSize", 10, articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("categoriesUrlName", "categories", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("tagsUrlName", "tags", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("searchUrlName", "search", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("categoriesPageName", "Categories", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("tagsPageName", "Tags", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("searchPageName", "Search results", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("blogTitle", "Articulate Blog", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("blogDescription", "Welcome to my blog", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("extractFirstImage", true, articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("redirectArchive", true, articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("blogLogo", @"{'focalPoint': {'left': 0.5,'top': 0.5},'src': '/media/articulate/default/logo.png','crops': []}", articulateType, _localizationService);
            root.SetInvariantOrDefaultCultureValue("blogBanner", @"{'focalPoint': {'left': 0.5,'top': 0.5},'src': '/media/articulate/default/banner.jpg','crops': []}", articulateType, _localizationService);

            var result = _contentService.SaveAndPublish(root);

            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate root node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }

            //get the authors and archive nodes and publish them
            _logger.Info <ArticulateDataInstaller>("Publishing authors and archive nodes");
            var children = _contentService.GetPagedChildren(root.Id, 0, 10, out var total).ToList();
            var archive  = children.FirstOrDefault(x => x.ContentType.Alias == ArticulateConstants.ArticulateArchiveContentTypeAlias);

            if (archive == null)
            {
                _logger.Warn <ArticulateDataInstaller>("Articulate archive node was not created, cannot proceed to publish");
                return(null);
            }
            result = _contentService.SaveAndPublish(archive);
            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate archive node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }

            var authors = children.FirstOrDefault(x => x.ContentType.Alias == ArticulateConstants.ArticulateAuthorsContentTypeAlias);

            if (authors == null)
            {
                _logger.Warn <ArticulateDataInstaller>("Articulate authors node was not created, cannot proceed to publish");
                return(null);
            }
            result = _contentService.SaveAndPublish(authors);
            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate authors node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }

            var authorType = _contentTypeService.Get("ArticulateAuthor");

            if (authorType == null)
            {
                _logger.Warn <ArticulateDataInstaller>("No 'ArticulateAuthor' content type found");
                return(null);
            }

            //Create the author
            _logger.Info <ArticulateDataInstaller>("Creating demo author");
            var author = _contentService.CreateWithInvariantOrDefaultCultureName("Jane Doe", authors.Id, authorType, _localizationService);

            author.SetInvariantOrDefaultCultureValue("authorBio", "Jane Doe writes articles for businesses who love coffee as much as she does. Her articles have appeared in a number of coffee related magazines such as beanscenemag.com.au and dailycoffeenews.com. Her articles focus on the health benefits coffee has to offer –but never at the expense of providing an entertaining read.", authorType, _localizationService);
            author.SetInvariantOrDefaultCultureValue("authorUrl", "https://github.com/shazwazza/articulate", authorType, _localizationService);
            author.SetInvariantOrDefaultCultureValue("authorImage", @"{'focalPoint': {'left': 0.5,'top': 0.5},'src': '/media/articulate/default/author.jpg','crops': []}", authorType, _localizationService);

            result = _contentService.SaveAndPublish(author);
            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate author node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }


            //Create a test posts
            _logger.Info <ArticulateDataInstaller>("Creating test blog post 1");

            var markdownType = _contentTypeService.Get("ArticulateMarkdown");

            if (markdownType == null)
            {
                _logger.Warn <ArticulateDataInstaller>("No 'ArticulateMarkdown' content type found");
                return(null);
            }
            var post1 = _contentService.CreateWithInvariantOrDefaultCultureName("Welcome", archive.Id, markdownType, _localizationService);

            post1.SetInvariantOrDefaultCultureValue("author", "Jane Doe", markdownType, _localizationService);
            post1.SetInvariantOrDefaultCultureValue("excerpt", "Hi! Welcome to blogging with Articulate :) This is a fully functional blog engine supporting many features.", markdownType, _localizationService);
            post1.AssignInvariantOrDefaultCultureTags("categories", new[] { "Articulate" }, markdownType, _localizationService);
            post1.AssignInvariantOrDefaultCultureTags("tags", new[] { "Cafe", "Markdown" }, markdownType, _localizationService);
            post1.SetInvariantOrDefaultCultureValue("publishedDate", DateTime.Now, markdownType, _localizationService);
            post1.SetInvariantOrDefaultCultureValue("postImage", @"{'focalPoint': {'left': 0.5,'top': 0.5},'src': '/media/articulate/default/post1.jpg','crops': []}", markdownType, _localizationService);
            post1.SetInvariantOrDefaultCultureValue("socialDescription", "Welcome to blogging with Articulate, a fully functional blog engine supporting all of the blogging features you'd want.", markdownType, _localizationService);
            post1.SetInvariantOrDefaultCultureValue("markdown", @"## Hi! Welcome to Articulate :)

This is a fully functional blog engine supporting many features:

* Categories & Tags
* Themes
* Live Writer support
* Markdown support
* Easily post from your mobile phone including adding images and photos direct from you camera
* Disqus or Facebook comment support (or build your own)
* Search
* Blogml import/export
* RSS
* Customizable urls
* Author profiles

Articulate is open source and hosted on GitHub:
[https://github.com/Shandem/Articulate/](https://github.com/Shandem/Articulate)

It comes with a few themes which have different features enabled. You can easily change themes on the root Articulate node on the style tab. Themes are super easy to create and in fact the 4 themes shipped with Articulate are MIT licensed themes originally built for the Ghost blogging platform.

Comments are powered by Disqus (Facebook or custom comment engines can be used which can be enabled in the templates).

Live Writer integration is fully functional, to configure Live Writer just use the URL of the Articulate root node and use your Umbraco username/password.

You can post directly from your mobile (including images and photos). This editor can be found at the path of ""/a-new"". Click [Here](../a-new) to see it in action. Now you can post your thoughts wherever you are, from a cafe, on the road, etc... all without needing your computer. 

Enjoy!", markdownType, _localizationService);

            result = _contentService.SaveAndPublish(post1);
            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate post node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }

            var post2 = _contentService.CreateWithInvariantOrDefaultCultureName("Latte art", archive.Id, markdownType, _localizationService);

            post2.SetInvariantOrDefaultCultureValue("author", "Jane Doe", markdownType, _localizationService);
            post2.SetInvariantOrDefaultCultureValue("excerpt", "Latte art is a method of preparing coffee created by pouring steamed milk into a shot of espresso, resulting in a pattern or design on the surface of the latte. ", markdownType, _localizationService);
            post2.AssignInvariantOrDefaultCultureTags("categories", new[] { "Coffee" }, markdownType, _localizationService);
            post2.AssignInvariantOrDefaultCultureTags("tags", new[] { "Cafe", "Milk", "Espresso" }, markdownType, _localizationService);
            post2.SetInvariantOrDefaultCultureValue("publishedDate", DateTime.Now.AddDays(-10), markdownType, _localizationService);
            post2.SetInvariantOrDefaultCultureValue("postImage", @"{'focalPoint': {'left': 0.5,'top': 0.5},'src': '/media/articulate/default/post2.jpg','crops': []}", markdownType, _localizationService);
            post2.SetInvariantOrDefaultCultureValue("socialDescription", "Latte art is a method of preparing coffee created by pouring steamed milk into a shot of espresso, resulting in a pattern or design on the surface of the latte. ", markdownType, _localizationService);
            post2.SetInvariantOrDefaultCultureValue("markdown", @"Latte art is a method of preparing coffee created by pouring steamed milk into a shot of espresso, resulting in a pattern or design on the surface of the latte. Latte art is hard to create consistently because of the many factors involved with creating coffee, from the coffee acidity, temperature, to the type of milk and equipment being used. Don't expect that you'll be able to make latte art the first time you try, in fact it will probably take you a great number of tries to make something work and you'll be hoping that you're using some quality equipment, otherwise you'll stand no chance.

Good latte art means you've found a cafe with a good barista so there's a good chance if you're seeing a a great design in your coffee, it's also going to taste wonderful.", markdownType, _localizationService);

            result = _contentService.SaveAndPublish(post2);
            if (!result.Success)
            {
                _logger.Warn <ArticulateDataInstaller>("Could not create Articulate post node, saving failed with status {Status}, invalid properties are {InvalidProperties} ", result.Result, string.Join(", ", result.InvalidProperties.Select(x => x.Alias)));
                return(null);
            }

            return(root);
        }
Esempio n. 3
0
        private IDictionary <string, string> ImportAuthors(int userId, IContent rootNode, IEnumerable <BlogMLAuthor> authors)
        {
            var result = new Dictionary <string, string>();

            var authorType = _contentTypeService.Get("ArticulateAuthor");

            if (authorType == null)
            {
                throw new InvalidOperationException("Articulate is not installed properly, the ArticulateAuthor doc type could not be found");
            }

            var authorsType = _contentTypeService.Get(ArticulateConstants.ArticulateAuthorsContentTypeAlias);

            if (authorsType == null)
            {
                throw new InvalidOperationException("Articulate is not installed properly, the ArticulateAuthors doc type could not be found");
            }

            // get the authors container node for this articulate root
            var allAuthorsNodes = _contentService.GetPagedOfType(
                authorsType.Id,
                0,
                int.MaxValue,
                out long totalAuthorsNodes,
                _sqlContext.Query <IContent>().Where(x => x.ParentId == rootNode.Id && x.Trashed == false));

            var authorsNode = allAuthorsNodes.FirstOrDefault();

            if (authorsNode == null)
            {
                //create the authors node
                authorsNode = _contentService.CreateWithInvariantOrDefaultCultureName(ArticulateConstants.AuthorsDefaultName, rootNode, authorsType, _localizationService);

                _contentService.SaveAndPublish(authorsNode, userId: userId);
            }

            // get the authors nodes for this authors container
            var allAuthorNodes = _contentService.GetPagedOfType(
                authorType.Id,
                0,
                int.MaxValue,
                out long totalAuthorNodes,
                _sqlContext.Query <IContent>().Where(x => x.ParentId == authorsNode.Id && x.Trashed == false));


            foreach (var author in authors)
            {
                //first check if a user exists by email
                var found = _userService.GetByEmail(author.EmailAddress);
                if (found != null)
                {
                    //check if an author node exists for this user
                    var authorNode = allAuthorNodes.FirstOrDefault(x => x.Name.InvariantEquals(found.Name));

                    //nope not found so create a node for this user name
                    if (authorNode == null)
                    {
                        //create an author with the same name as the user - we'll need to wire up that
                        // name to posts later on
                        authorNode = _contentService.CreateWithInvariantOrDefaultCultureName(found.Name, authorsNode, authorType, _localizationService);

                        _contentService.SaveAndPublish(authorNode, userId: userId);
                    }

                    result.Add(author.Id, authorNode.Name);
                }
                else
                {
                    //no user existsw with this email, so check if a node exists with the current author's title
                    var authorNode = allAuthorNodes.FirstOrDefault(x => x.Name.InvariantEquals(author.Title.Content));

                    //nope, not found so create one
                    if (authorNode == null)
                    {
                        //create a new author node with this title
                        authorNode = _contentService.CreateWithInvariantOrDefaultCultureName(author.Title.Content, authorsNode, authorType, _localizationService);

                        _contentService.SaveAndPublish(authorNode, userId: userId);
                    }

                    result.Add(author.Id, authorNode.Name);
                }
            }

            return(result);
        }