コード例 #1
0
        public HTMLPage PageForSection(Act act, Section section)
        {
            var div     = new Div(cls: "LegSnippet");
            var builder = new AmendmentBuilder(0, false);

            section.WriteTo(div, 1, builder);
            if (builder.Performed.Count > 0)
            {
                div.Children.Add(builder.GetDiv());
            }
            var page = new HTMLPage()
            {
                Children =
                {
                    new PageHeader()
                    .WithStyle("https://www.legislation.gov.uk/styles/legislation.css")
                    .WithStyle("https://www.legislation.gov.uk/styles/primarylegislation.css")
                    .WithMeta(Meta.Charset("UTF-8"))
                    .WithOpenGraph(title: $"{act.ShortTitle} Section {section.Number}",
                                   description: section.Header),
                    new PageBody()
                    {
                        Children = { div }
                    }
                }
            };

            return(page);
        }
コード例 #2
0
        public override void WriteTo(HTMLBase parent, int depth, AmendmentBuilder builder)
        {
            var act = this.Law;
            var LHS = new HTMLHelpers.Objects.Span(HierarchyId, $"LegDS LegLHS LegP{depth}No")
            {
                RawText = $"({Number})"
            };
            var RHS = new HTMLHelpers.Objects.Span(cls: $"LegDS LegRHS LegP{depth}Text")
            {
                RawText = getAmendedText(builder)
            };
            var p = new HTMLHelpers.Objects.Paragraph(null, null, $"LegClearFix LegP{depth}Container")
            {
                Children =
                {
                    LHS, RHS
                }
            };

            parent.Children.Add(p);
            if (RepealedById.HasValue)
            {
                var next = builder.GetNextNumber(new ThingAmendment(this, RepealedById.Value, AmendType.Repeal));
                RHS.RawText = builder.TextOnly ? "..." : ". . . ." + LegHelpers.GetChangeAnchor(next);
                return;
            }
            else if (Substituted != null)
            {
                parent.Children.RemoveAt(parent.Children.Count - 1); // remove p, since we'll refer to the substituted
                Substituted.New.Register(Parent);
                Substituted.New.Number         = Number;
                Substituted.New.SubstituedById = Substituted.GroupId;
                Substituted.New.WriteTo(parent, depth, builder);
                return;
            }
            else if (SubstituedById.HasValue && Parent.SubstituedById != SubstituedById)
            {
                var next = builder.GetNextNumber(new ThingAmendment(this, SubstituedById.Value, AmendType.Substitute));
                LHS.RawText = (builder.TextOnly ? "" : $"{LegHelpers.GetChangeDeliminator(true)}{LegHelpers.GetChangeAnchor(next)}") + $"({Number})";
            }
            else if (InsertedById.HasValue && Parent.InsertedById != InsertedById)
            {
                var next = builder.GetNextNumber(new ThingAmendment(this, InsertedById.Value, AmendType.Insert));
                LHS.RawText = (builder.TextOnly ? "" : $"{LegHelpers.GetChangeDeliminator(true)}{LegHelpers.GetChangeAnchor(next)}") + $"({Number})";
            }
            foreach (var child in Children)
            {
                child.WriteTo(parent, depth + 1, builder);
            }
            if (!builder.TextOnly && (
                    (InsertedById.HasValue && Parent.InsertedById != InsertedById)
                    ||
                    (SubstituedById.HasValue && Parent.SubstituedById != SubstituedById)
                    )
                )
            {
                var last = parent.Children[^ 1];
コード例 #3
0
ファイル: Act.cs プロジェクト: TheGrandCoding/discord-bot
        public HTMLBase GetDiv(bool printTextOnly)
        {
            this.Register(null);
            var div = new Div(cls: "LegSnippet");

            div.Children.Add(GetPrelimBlock());
            var children = new List <Section>();

            children.AddRange(Children);
            int count          = 1;
            int amendmentCount = 0;

            foreach (var child in children.OrderBy(x => x.Number, new NumberComparer()))
            {
                if (child.Number == null)
                {
                    child.Number = $"{count}";
                    if (!child.Group)
                    {
                        count++;
                    }
                }
                // Amendments applied at the Act-level should either be:
                // a) Appeal an entire section
                // b) Insert an entire section
                // As such, there can only be one of each.
                // It's possible that an inserted section is repealed - but we'll handle repeals first anyway.
                var builder = new AmendmentBuilder(amendmentCount, printTextOnly);

                child.WriteTo(div, 1, builder);
                if (builder.Performed.Count > 0)
                {
                    amendmentCount += builder.Performed.Count;
                    if (!builder.TextOnly)
                    {
                        div.Children.Add(builder.GetDiv());
                    }
                }
            }
            return(div);
        }
コード例 #4
0
ファイル: Act.cs プロジェクト: TheGrandCoding/discord-bot
 public override void WriteTo(HTMLBase parent, int depth, AmendmentBuilder builder)
 { // not used.
     throw new NotImplementedException();
 }
コード例 #5
0
ファイル: Section.cs プロジェクト: TheGrandCoding/discord-bot
        public override void WriteTo(HTMLBase parent, int depth, AmendmentBuilder builder)
        {
            if (Group)
            {
                parent.Children.Add(new Div(cls: "LegClearPblock"));
                parent.Children.Add(new H2(cls: "LegPblock")
                {
                    Children =
                    {
                        new Span(cls: "LegPblockTitle")
                        {
                            RawText = getAmendedText(builder)
                        }
                    }
                });
                return;
            }
            var LHS = new Span(cls: $"LegDS LegP{depth}No")
            {
                RawText = Number
            };
            var RHS = new Span(cls: $"LegDS LegP{depth}GroupTitle")
            {
                RawText = getAmendedText(builder)
            };
            var header = new H3($"section-{Number}", $"LegClearFix LegP{depth}Container{(Number == "1" ? "First" : "")}")
            {
                Children =
                {
                    new Anchor("", id: AnchorText),
                    LHS,
                    RHS
                }
            };

            parent.Children.Add(header);
            if (RepealedById.HasValue)
            {
                var amend = Law.AmendmentReferences[RepealedById.Value];
                var next  = builder.GetNextNumber(new ThingAmendment(this, RepealedById.Value, AmendType.Repeal));
                RHS.RawText = builder.TextOnly ? "..." : ". . . ." + LegHelpers.GetChangeAnchor(next);
                return;
            }
            else if (Substituted != null)
            {
                parent.Children.RemoveAt(parent.Children.Count - 1); // remove p, since we'll refer to the substituted
                Substituted.New.Register(Parent);
                Substituted.New.Number         = Number;
                Substituted.New.SubstituedById = Substituted.GroupId;
                Substituted.New.WriteTo(parent, depth, builder);
                return;
            }
            else if (SubstituedById.HasValue && Parent.SubstituedById != SubstituedById)
            {
                var next = builder.GetNextNumber(new ThingAmendment(this, SubstituedById.Value, AmendType.Substitute));
                LHS.RawText = (builder.TextOnly ? "" : $"{LegHelpers.GetChangeDeliminator(true)}{LegHelpers.GetChangeAnchor(next)}") + $"{Number}";
            }
            else if (InsertedById.HasValue)
            {
                var amend = Law.AmendmentReferences[InsertedById.Value];
                var next  = builder.GetNextNumber(new ThingAmendment(this, InsertedById.Value, AmendType.Insert));
                LHS.RawText = (builder.TextOnly ? "" : $"{LegHelpers.GetChangeDeliminator(true)}{LegHelpers.GetChangeAnchor(next)}") + $"{Number}";
            }
            var children = new List <TextualLawThing>();

            children.AddRange(Children);
            foreach (var child in children.OrderBy(x => x.Number, new NumberComparer()))
            {
                child.WriteTo(parent, depth + 1, builder);
            }
            if (!builder.TextOnly &&
                (
                    InsertedById.HasValue
                    ||
                    SubstituedById.HasValue
                )
                )
            {
                var last           = parent.Children[^ 1];
コード例 #6
0
ファイル: Section.cs プロジェクト: TheGrandCoding/discord-bot
        string getAmendedText(AmendmentBuilder builder)
        {
            var amender = new TextAmenderBuilder(Header, builder, TextAmendments);

            return(builder.TextOnly ? amender.NiceWords : amender.RawText);
        }
コード例 #7
0
 public abstract void WriteTo(HTMLHelpers.HTMLBase parent, int depth, AmendmentBuilder builder);