예제 #1
0
        public IEnumerable <IDelta> DetermineDeltas(TopicToken originalRoot)
        {
            var original = originalRoot.Find(Id);

            if (original == null)
            {
                yield return(new NewTopic(this));
            }
            else
            {
                if (original.File != File)
                {
                    yield return(new MoveTopic(original.File, File));
                }

                if (original.Title != Title)
                {
                    yield return(new RewriteTitle(File, Title));
                }

                if (original.Url != Url)
                {
                    yield return(new RewriteUrl(File, Url));
                }
            }
        }
예제 #2
0
        private void findDeletedTopics(TopicToken original, TopicToken @new)
        {
            var deletedTopics = original.All().Where(x => @new.Find(x.Id) == null)
                                .Select(x => new DeleteTopic(x));

            _deltas.AddRange(deletedTopics);
        }
예제 #3
0
        public TopicTreeTag(TopicToken token) : base("div")
        {
            AddClass("dd");
            Id("topic-tree");

            Append(new TopicNodeTag(new [] { token }));
        }
예제 #4
0
        public static TopicToken LoadIndex(string directory)
        {
            var root  = TopicLoader.LoadFromFolder(directory);
            var token = new TopicToken(root.Index);

            token.Key = "index";

            return(token);
        }
예제 #5
0
        public void RewriteTopicStructure(string projectName, TopicToken newStructure)
        {
            var original = _tokens[projectName];

            var collector = new DeltaCollector(original, newStructure);

            collector.ExecuteDeltas();

            // Want the new one in on the next try.
            _tokens.Remove(projectName);
        }
예제 #6
0
        private void findNewAndDeletedFolders(TopicToken original, TopicToken @new)
        {
            var oldFolders = original.All().Select(x => x.Folder).Distinct().ToList();
            var newFolders = @new.All().Select(x => x.Folder).Distinct().ToList();

            var deletedFolders = oldFolders.Where(x => !newFolders.Contains(x)).Select(x => new DeleteFolder(x));

            _deltas.AddRange(deletedFolders);

            var addedFolders = newFolders.Where(x => !oldFolders.Contains(x)).Select(x => new CreateFolder(x));

            _deltas.AddRange(addedFolders);
        }
예제 #7
0
        public DeltaCollector(TopicToken original, TopicToken @new)
        {
            @new.DeterminePaths(original.Folder);

            findDeletedTopics(original, @new);
            findNewAndDeletedFolders(original, @new);

            @new.All().Each(x => {
                var topicDeltas = x.DetermineDeltas(original);

                _deltas.AddRange(topicDeltas);
            });
        }
예제 #8
0
        public TopicToken Clone()
        {
            var clone = new TopicToken
            {
                Url     = Url,
                Key     = Key,
                FullKey = FullKey,
                Title   = Title,
                File    = File,
                Folder  = Folder,
                Id      = Id
            };

            clone.Children.AddRange(Children.Select(x => x.Clone()));
            clone.assignOrders();

            return(clone);
        }
예제 #9
0
        public TopicListItemTag(TopicToken token) : base("li")
        {
            AddClass("dd-item");
            AddClass("dd3-item");

            Data("id", token.Id);
            Data("title", token.Title);
            Data("url", token.Url);
            Data("key", token.Key);

            Add("div").AddClass("dd-handle").AddClass("dd3-handle");
            var contentTag = Add("div").AddClass("dd3-content");

            contentTag.Add("span").AddClass("topic-title").Text(token.Title);

            if (token.Key != "index")
            {
                contentTag.Add("a").AddClass("close").Data("dismiss", "alert").Text("&times;").Encoded(false);
            }


            Append(new TopicNodeTag(token.Children));
        }
예제 #10
0
        public AjaxContinuation post_project_ProjectName(TopicToken topic)
        {
            if (_lastTimestamp == _reloaded.Timestamp.ToString())
            {
                return(AjaxContinuation.Successful());
            }

            var existing      = _tokenCache.TopicStructureFor(topic.ProjectName);
            var collector     = new DeltaCollector(existing, topic);
            var orderedDeltas = collector.OrderedDeltas().ToArray();

            orderedDeltas.Each(x => Debug.WriteLine(x));

            collector.ExecuteDeltas();

            Task.Factory.StartNew(() => {
                EventAggregator.SendMessage(new RecycleApplication());
            });

            _lastTimestamp = _reloaded.Timestamp.ToString();

            return(AjaxContinuation.Successful());
        }
예제 #11
0
 public NewTopic(TopicToken token)
 {
     _token = token;
 }
예제 #12
0
 public void AddChild(TopicToken child)
 {
     Children.Add(child);
     assignOrders();
 }
예제 #13
0
 protected bool Equals(TopicToken other)
 {
     return(Id.Equals(other.Id));
 }
예제 #14
0
 public DeleteTopic(TopicToken token)
 {
     _file = token.File;
 }