/// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ Topic[] topics = YearDiary.GetAllTopics(); if(topics.Length == 0) return NotFound(); string yearTitle = YearDiary.Dates[0].ToString(YearFormat); Response.SelfTitle = myModel.BaseTitle; Response.BaseTitle = Diary.BaseTitle; InsertHeading(2, yearTitle); Html.Append(DiaryHeadingList(topics, 3)); Topic newestTopic = topics[0]; Topic oldestTopic = topics[topics.Length - 1]; // 次ページ (一つ前の日記) DateTime prevDate = GetPrevDate(oldestTopic.Date); if(prevDate != default(DateTime)){ AbsPath prevPath = myModel.ParentXml.BasePath.Combine(prevDate.Year); string prevTitle = string.Format("{0}の{1}", prevDate.ToString(YearFormat), myModel.TopicSuffix); Prev = new LinkItem(prevPath, prevTitle); } DateTime nextDate = GetNextDate(newestTopic.Date); if(nextDate != default(DateTime)){ AbsPath nextPath = myModel.ParentXml.BasePath.Combine(nextDate.Year); string nextTitle = string.Format("{0}の{1}", nextDate.ToString(YearFormat), myModel.TopicSuffix); Next = new LinkItem(nextPath, nextTitle); } return Response; }
/// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ Topic[] topics = GetRecentTopics(); if(topics.Length == 0) return NotFound(); Topic oldestTopic = topics[topics.Length-1]; int year = oldestTopic.Date.Year; YearDiary oldestDiary = Diary.GetYearDiary(year); Response.SelfTitle = Label; InsertHeading(2, Label); Html.Append(DiaryListWithDate(topics, 3)); // 次ページ (一つ前の日) DateTime prevDate = GetPrevDate(oldestTopic.Date); if(prevDate != default(DateTime)){ AbsPath prevPath = myModel.BasePath.Combine(prevDate.Year, prevDate.Month, prevDate.Day); string prevTitle = string.Format("{0}の{1}", prevDate.ToString(DateFormat), myModel.TopicSuffix); Prev = new LinkItem(prevPath, prevTitle); } //RSSオートディスカバリ LinkItem rssLink = new LinkItem(BasePath.Combine(DiaryIndexRss.Id), Label + "(RSS1.0)"); Html.AddLinkRel("alternate", HatomaruResponse.RssMediaType, rssLink); LinkItem atomLink = new LinkItem(BasePath.Combine(DiaryIndexAtom.Id), Label + "(Atom1.0)"); Html.AddLinkRel("alternate", HatomaruResponse.AtomMediaType, atomLink); return Response; }
/// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ if(myDate == default(DateTime)) return NotFound(); // 翌月の最初の日の 00:00:00.0000 DateTime endDate = myDate.Month == 12 ? new DateTime(myDate.Year + 1, 1, 1) : new DateTime(myDate.Year, myDate.Month + 1, 1); Topic[] topics = YearDiary.GetSpanTopics(myDate, endDate); if(topics.Length == 0) return NotFound(); string monthTitle = myDate.ToString(MonthFormat, Model.Manager.IniData.CultureInfo); Response.AddTopicPath(myModel.BasePath.Combine(myDate.Month), monthTitle); Response.SelfTitle = monthTitle; Response.BaseTitle = Diary.BaseTitle; InsertHeading(2, monthTitle); Html.Append(DiaryListWithDate(topics, 3)); Topic newestTopic = topics[0]; Topic oldestTopic = topics[topics.Length - 1]; // 次ページ (一つ前の日記) DateTime prevDate = GetPrevDate(oldestTopic.Date); if(prevDate != default(DateTime)){ AbsPath prevPath = myModel.ParentXml.BasePath.Combine(prevDate.Year, prevDate.Month); string prevTitle = string.Format("{0}の{1}", prevDate.ToString(MonthFormat), myModel.TopicSuffix); Prev = new LinkItem(prevPath, prevTitle); } DateTime nextDate = GetNextDate(newestTopic.Date); if(nextDate != default(DateTime)){ AbsPath nextPath = myModel.ParentXml.BasePath.Combine(nextDate.Year, nextDate.Month); string nextTitle = string.Format("{0}の{1}", nextDate.ToString(MonthFormat), myModel.TopicSuffix); Next = new LinkItem(nextPath, nextTitle); } return Response; }
/// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ if(myDate == default(DateTime)) return NotFound(); Topic[] topics = YearDiary.GetDayTopics(myDate); if(topics.Length == 0) return NotFound(); string monthTitle = myDate.ToString(MonthFormat, Model.Manager.IniData.CultureInfo); Response.AddTopicPath(myModel.BasePath.Combine(myDate.Month), monthTitle); string dateTitle = myDate.ToString(DateFormat, Model.Manager.IniData.CultureInfo); Response.AddTopicPath(myModel.BasePath.Combine(myDate.Month, myDate.Day), dateTitle); Response.SelfTitle = dateTitle; Response.BaseTitle = Diary.BaseTitle; InsertHeading(2, dateTitle); for(int i=0; i < topics.Length; i++){ Html.Append(GetTopicBody(topics[i], 3)); } // 次ページ (一つ前の日記) DateTime prevDate = GetPrevDate(myDate); if(prevDate != default(DateTime)){ AbsPath prevPath = myModel.ParentXml.BasePath.Combine(prevDate.Year, prevDate.Month, prevDate.Day); string prevTitle = string.Format("{0}の{1}", prevDate.ToString(DateFormat), myModel.TopicSuffix); Prev = new LinkItem(prevPath, prevTitle); } DateTime nextDate = GetNextDate(myDate); if(nextDate != default(DateTime)){ AbsPath nextPath = myModel.ParentXml.BasePath.Combine(nextDate.Year, nextDate.Month, nextDate.Day); string nextTitle = string.Format("{0}の{1}", nextDate.ToString(DateFormat), myModel.TopicSuffix); Next = new LinkItem(nextPath, nextTitle); } return Response; }
// プロパティ /// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ InsertHeading(2, myModel.BaseTitle); foreach(DocTopic dt in Doc.AnonymousTopics){ Html.Append(ParseNode(dt.SectionElement, 3)); } DocTopic[] topics = Doc.GetAllNamedTopics(); if(topics != null && topics.Length > 0){ XmlElement ul = Html.Create("ul"); foreach(DocTopic dt in topics){ XmlElement li = Html.Create("li"); AbsPath path = myModel.BasePath.Combine(dt.Id); XmlElement a = Html.A(path); a.InnerText = dt.FullName; li.AppendChild(a); ul.AppendChild(li); } Html.Append(ul); } Html.Append(CommentLink(myModel.BasePath, myModel.BaseTitle)); DocTopic firstTopic = Doc.GetFirstTopic(); if(firstTopic != null){ Next = new LinkItem(myModel.BasePath.Combine(firstTopic.Id), firstTopic.FullName); } return myResponse; }
// プロパティ /// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ DocTopic dt = Doc.GetTopicById(mySectionId); if(dt == null) return Redirect(myModel.BasePath); InsertHeading(2, dt.FullName); Html.Append(ParseNode(dt.SectionElement, 3)); // FootNoteList があれば吐き出す Response.SelfTitle = dt.FullName; Response.AddTopicPath(myPath, dt.FullName); if(myFootNoteCount > 0){ XmlElement fnDiv = Html.Div("footnotes"); XmlElement fnH = Html.H(4, null, "注釈"); fnDiv.AppendChild(fnH); fnDiv.AppendChild(ParseFootNoteList()); Html.Append(fnDiv); } Html.Append(CommentLink(Path, dt.FullName)); DocTopic prevTopic = Doc.GetPrevTopic(dt); if(prevTopic != null){ Prev = new LinkItem(myModel.BasePath.Combine(prevTopic.Id), prevTopic.FullName); } else { Prev = new LinkItem(myModel.BasePath, "目次"); } DocTopic nextTopic = Doc.GetNextTopic(dt); if(nextTopic != null){ Next = new LinkItem(myModel.BasePath.Combine(nextTopic.Id), nextTopic.FullName); } else { Next = new LinkItem(myModel.BasePath, "目次"); } return myResponse; }
/// <summary> /// データを GET し、HatomaruResponse を取得します。 /// </summary> protected override HatomaruResponse GetHtmlResponse(){ Topic[] topics = GetUpdatedTopics(); if(topics.Length == 0) return NotFound(); Response.SelfTitle = Label; Response.AddTopicPath(Path, Label); InsertHeading(2, Label); XmlElement ul = Html.Create("ul"); foreach(Topic t in topics){ XmlElement li = Html.Create("li", null, MakeTopicAnchor(t), Html.Space, GetUpdated(t)); ul.AppendChild(li); } Html.Append(ul); LinkItem atomLink = new LinkItem(BasePath.Combine(Id, DiaryIndexUpdatedAtom.Id), DiaryIndexUpdatedAtom.Label + "(Atom1.0)"); Html.AddLinkRel("alternate", HatomaruResponse.AtomMediaType, atomLink); return Response; }
/// <summary> /// ローカルナビゲーションをセットします。 /// </summary> protected void SetChildrenNav(LinkItem[] links){ XmlElement result = Html.Div("local-nav"); XmlElement resultUl = Html.Create("ul"); XmlElement resultLi = Html.Create("li"); result.AppendChild(resultUl); resultUl.AppendChild(resultLi); LinkItem item = Model.GetLinkItem(); XmlElement a = Html.A(item.Path, null, item.InnerText); resultLi.AppendChild(a); if(links != null && links.Length > 0){ XmlElement childUl = Html.Create("ul"); for(int i=0; i < links.Length; i++){ XmlElement childLi = Html.Create("li", null, Html.GetA(links[i])); childUl.AppendChild(childLi); } resultLi.AppendChild(childUl); } Html.Replace(NavName, result); }
// パブリックメソッド /// <summary> /// TopicPath に LinkItem を追加します。 /// </summary> public void AddTopicPath(LinkItem item){ myTopicPath.Add(item); }
// コンストラクタ /// <summary> /// 鳩丸データのデータソースの FileInfo と XmlDocument を指定して、HatomaruData のインスタンスを開始します。 /// </summary> protected HatomaruXml(HatomaruManager manager, FileInfo f, XmlDocument doc) : base(manager, f){ myDocument = doc; // ロード済み myMetaData = Document.DocumentElement[MetaName]; if(myMetaData == null) return; XmlElement title = myMetaData[TitleName]; if(title != null) myBaseTitle = title.InnerText; XmlElement desc = myMetaData[DescName]; if(desc != null) myDescription = desc.InnerText; XmlElement keywords = myMetaData[KeywordName]; if(keywords != null) myKeywords = keywords.InnerText; XmlElement topicSuffix = myMetaData[TopicSuffixName]; if(topicSuffix != null) myTopicSuffix = topicSuffix.InnerText; XmlNodeList styles = myMetaData.GetElementsByTagName(StyleName); foreach(XmlNode x in styles){ XmlElement e = x as XmlElement; if(x == null) continue; string linkHref = e.GetAttribute("href"); string linkTitle = e.GetAttribute("title"); linkHref = '/' + linkHref.TrimStart('/'); LinkItem s = new LinkItem(linkHref, linkTitle); myStyles.Add(s); } // 親 XML を取得 XmlNodeList indexes = myMetaData.GetElementsByTagName(IndexXmlName); if(indexes.Count > 0){ string indexXmlName = Util.GetAttributeValue(indexes[0], IndexXmlRefAttrName); if(!string.IsNullOrEmpty(indexXmlName)) myParentXml = GetDataByPathString(indexXmlName); } else if(!manager.RootXmlFile.FullName.Equals(f.FullName)){ myParentXml = manager.RootXml; } }
// オーバーライドメソッド protected override LinkItem[] GetSubNav(){ LinkItem[] result = new LinkItem[]{ new LinkItem(BasePath.Combine(HtmlRefViewElementList.Id), HtmlRefViewElementList.Label), new LinkItem(BasePath.Combine(HtmlRefViewElementGroupList.Id), HtmlRefViewElementGroupList.Label), new LinkItem(BasePath.Combine(HtmlRefViewAttributeList.Id), HtmlRefViewAttributeList.Label), new LinkItem(BasePath.Combine(HtmlRefViewAttributeGroupList.Id), HtmlRefViewAttributeGroupList.Label), new LinkItem(BasePath.Combine(HtmlRefViewDataList.Id), HtmlRefViewDataList.Label) }; return result; }
/// <summary> /// LinkItem を a要素に変換します。 /// </summary> public XmlElement GetA(LinkItem item){ if(item == null) return null; XmlElement result = A(item.Path, null, item.InnerText); return result; }
/// <summary> /// LinkItem を指定して、<link rel=stylesheet> を追加します。 /// </summary> public void AddStyleLink(LinkItem link){ AddLinkRel("stylesheet", "text/css", link); }
// メタ情報追加メソッド /// <summary> /// rel属性の値と type属性の値、LinkItem を指定して、<link rel="" href=""> を追加します。 /// </summary> public void AddLinkRel(string relValue, string typeValue, LinkItem item){ XmlElement link = this.Create("link"); link.SetAttribute("rel", relValue); link.SetAttribute("type", typeValue); link.SetAttribute("href", GetHref(item.Path)); if(!string.IsNullOrEmpty(item.InnerText)) link.SetAttribute("title", item.InnerText); this.Head.AppendChild(link); }