Ejemplo n.º 1
0
// コンストラクタ

		protected HatomaruActionBase(HatomaruXml model, AbsPath path){
			myModel = model;
			myUserPath = path;
			myPath = path;
			myResponse = new NormalResponse(model, myPath);
			GetHtml();
		}
Ejemplo n.º 2
0
// コンストラクタ

		/// <summary>
		/// アマ検の検索のためのアクションのインスタンスを開始します。
		/// </summary>
		public AmazonDoSearch(AmazonSearch model, AbsPath path, string query, AmazonIndexType ait, int page) : base(model, path){
			myPath = myModel.BasePath;
			myQuery = query;
			myIndexType = ait;
			myPageNum = page;
			if(myPageNum < 1) myPageNum = 1;
		}
Ejemplo n.º 3
0
// メソッド

		/// <summary>
		/// データを GET し、HatomaruResponse を取得します。
		/// </summary>
		protected override HatomaruResponse GetHtmlResponse(){
			InsertHeading(2, myModel.BaseTitle);
			Response.SelfTitle = myModel.BaseTitle;

			XmlElement ol = Html.Create("ol");

			XmlNodeList contents = Model.Document.GetElementsByTagName(HatomaruReputation.ContentElementName);
			
			int count = 0;
			foreach(XmlElement e in contents){
				string path = e.GetAttribute(HatomaruReputation.UriAttributeName);
				AbsPath absPath = new AbsPath(path);
				string title = myModel.Manager.GetResponseTitle(absPath);
				if(string.IsNullOrEmpty(title)) continue;
				
				XmlElement a = Html.A(absPath);
				a.InnerText = title;
				XmlElement li = Html.Create("li", null, a);

				string keywords = myModel.Manager.GetResponseKeywords(absPath);
				if(!string.IsNullOrEmpty(keywords)){
					li.AppendChild(Html.P(null, keywords));
				}
				ol.AppendChild(li);
				if(++count > MaxItem) break;
			}
			Html.Append(ol);
			return myResponse;
		}
Ejemplo n.º 4
0
		public string this[AbsPath uri]{
			get{
				string result = null;
				myData.TryGetValue(uri, out result);
				return result;
			}
		}
Ejemplo n.º 5
0
		/// <summary>
		/// path を元に、適切なコントローラを作成します。
		/// </summary>
		private HatomaruGetAction GetAction(AbsPath path){
			string pathStr = path.ToString();
			int qpos = pathStr.IndexOf('?');
			if(qpos > 0){
				path = new AbsPath(pathStr.Substring(0,qpos));
				string query = pathStr.Substring(qpos+1);
				string q = null;
				string i = null;
				string p = null;
				foreach(string pair in query.Split('&', ';')){
					int eqpos = pair.IndexOf('=');
					if(eqpos < 0) continue;
					string name = pair.Substring(0,eqpos);
					string val = pair.Substring(eqpos+1);
					switch(name){
						case QueryName:
						q = val;
						break;
						case IndexTypeName:
						i = val;
						break;
						case PageName:
						p = val;
						break;
					}
				}
				if(!string.IsNullOrEmpty(q)){
					AmazonIndexType index = AmazonIndexType.None;
					if(!string.IsNullOrEmpty(i)) index = (AmazonIndexType)Enum.Parse(typeof(AmazonIndexType), i, true);
					return new AmazonDoSearch(this, path, q.UrlDecode(), index, p.ToInt32());
				}
			}
			return new AmazonViewSearchForm(this, path);
		}
Ejemplo n.º 6
0
// コンストラクタ

		/// <summary>
		/// ジャンル表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public DiaryIndexViewGenre(DiaryIndex model, AbsPath path, string word) : base(model, path){
			myWord = word;
			if(string.IsNullOrEmpty(word)){
				myPath = BasePath.Combine(Id);
			} else {
				myPath = BasePath.Combine(Id, word);
			}
		}
Ejemplo n.º 7
0
// コンストラクタ

		/// <summary>
		/// 鳩丸データのデータソースの FileInfo を指定して、HatomaruData のインスタンスを開始します。
		/// </summary>
		protected HatomaruData(HatomaruManager manager, FileInfo f){
			myManager = manager;
			myFile = f;
			myLastModified = myFile.LastWriteTime;
			if(Manager.IniData.ExtInfo.ContainsKey(f.Extension.ToLower())){
				myExt = Manager.IniData.ExtInfo[f.Extension.ToLower()];
			}
			myBasePath = GetTrueFilePath();
		}
Ejemplo n.º 8
0
		/// <summary>
		/// データを GET し、HatomaruResponse を取得します。
		/// </summary>
		public override HatomaruResponse Get(AbsPath path){
/*
			HatomaruGetAction act = GetAction(path);
			HatomaruResponse result = act.Get();
			result.SetLastModified();
			return result;
*/
			return null;
		}
Ejemplo n.º 9
0
// メソッド

		public void Load(HatomaruManager manager, XmlElement contentElement){
			string path = contentElement.GetAttribute(HatomaruReputation.UriAttributeName);
			Path = new AbsPath(path);
			Count = contentElement.GetAttributeInt(HatomaruReputation.CountAttributeName);
			Description = contentElement[HatomaruReputation.DescriptionElementName];

			Title = manager.GetResponseTitle(Path);

		}
Ejemplo n.º 10
0
// コンストラクタ

		/// <summary>
		/// 記事を投稿順表示するアクションのインスタンスを開始します。
		/// </summary>
		public BbsViewOrder(HatomaruBbs model, AbsPath path, int page) : base(model, path){
			if(page <= 1){
				myPageNum = 1;
				myPath = myModel.BasePath.Combine(Id);
			} else {
				myPageNum = page;
				myPath = myModel.BasePath.Combine(Id, myPageNum.ToString());
			}
		}
Ejemplo n.º 11
0
		public void Add(AbsPath uri, string data){
			string prevdata = this[uri];
			if(prevdata == null){
				myData.Add(uri, data);
				Save();
			} else if(prevdata != data){
				myData[uri] = data;
				Save();
			}
		}
Ejemplo n.º 12
0
// オーバーライドメソッド

		/// <summary>
		/// データを GET し、HatomaruResponse を取得します。
		/// </summary>
		public override HatomaruResponse Get(AbsPath path){
			XmlElement e = this.Document.DocumentElement;
			string targetPath = e.GetAttributeValue(PathAttrName);
			if(string.IsNullOrEmpty(targetPath)){
				throw new Exception(string.Format("{0}要素に{1}属性がないか、値が空です。", Name, PathAttrName));
			}
			AbsPath redPath = new AbsPath(targetPath);
			
			return new RedirectResponse(redPath, Manager.IniData.Domain);

		}
Ejemplo n.º 13
0
// パブリックメソッド

		/// <summary>
		/// データを GET し、HatomaruResponse を取得します。
		/// ファイルのパスが正しくなければリダイレクトします (拡張子の有無のみ許容します)
		/// </summary>
		public override HatomaruResponse Get(AbsPath path){
			FileResponse result = new FileResponse(this, Ext);

			if(path != BasePath && path != BasePath.CombineExtension(File.Extension)){
				return new RedirectResponse(BasePath, Manager.IniData.Domain);
			}

			result.Path = BasePath;
			result.SetLastModified();
			return result;
		}
Ejemplo n.º 14
0
		public void Load(){
			if(!myFile.Exists) return;
			using(FileStream fs = myFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
			using(StreamReader sr = new StreamReader(fs)){
				while (sr.Peek() >= 0){
					string line = sr.ReadLine();
					string[] data = line.Split('\t');
					if(data.Length < 2) continue;
					AbsPath ap = new AbsPath(data[0]);
					myData.Add(ap, data[1]);
				}
			}
		}
Ejemplo n.º 15
0
// コンストラクタ
		public BbsPostAction(HatomaruXml model, AbsPath path, HttpRequest req) : base(model, path, req){
			string[] fragments = path.GetFragments(BasePath);
			if(model is HatomaruBbs){
				if(fragments.Length > 1 && fragments[0].Equals(BbsViewArticle.Id)){
					int articleId = fragments[1].ToInt32();
					myTargetArticle = Bbs.GetArticle(articleId);
				}
			} else {
				myTargetArticle = new Article();
				myTargetArticle.CommentTo = path.RemoveLast(CommentPath);
			}
			myResponse = new NoCacheResponse(Model, path);
			GetHtml();
		}
Ejemplo n.º 16
0
// コンストラクタ

		/// <summary>
		/// ジャンル表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public GlossaryViewGenreList(HatomaruGlossary model, AbsPath path) : base(model, path){
			myPath = BasePath.Combine(Id);
		}
Ejemplo n.º 17
0
		/// <summary>
		/// 現在のコンテンツにページナビゲーションをセットします。
		/// </summary>
		protected void InsertPageNav(Pager pg, AbsPath path){
			if(myPageNav == null){
				myPageNav = pg.GetPageNav(Html, path);
			}
			Html.Entry.AppendChild(myPageNav.Clone());
		}
Ejemplo n.º 18
0
// コンストラクタ

		public ReputationView(HatomaruXml model, AbsPath path) : base(model, path){}
Ejemplo n.º 19
0
		public ForbiddenResponse(HatomaruXml source, AbsPath path, string message) : base(source, path, 403, message){}
Ejemplo n.º 20
0
		/// <summary>
		/// コメントへのリンクを取得します。
		/// </summary>
		protected XmlNode CommentLink(AbsPath path, string title){

			XmlNode result = Html.Create("ul", "comment-link");
			XmlElement resultLi = Html.Create("li");

			Response.AddDataSource(Bbs);
			BbsThread bt = Bbs.GetCommentToThread(path);
			AbsPath commentPath = path.Combine(CommentPath);

			XmlElement commentA = Html.A(commentPath);
			if(bt == null || bt.Articles.Length == 0){
				commentA.InnerText = string.Format("「{0}」に{1}を書く", title, CommentName);
			} else {
				commentA.InnerText = string.Format("「{0}」への{1} ({2}件)", title, CommentName, bt.Count);
			}
			resultLi.AppendChild(commentA);
			result.AppendChild(resultLi);
			return result;
		}
Ejemplo n.º 21
0
		/// <summary>
		/// パスとテキストを指定して、TopicPath に LinkItem を追加します。
		/// </summary>
		public void AddTopicPath(AbsPath path, string innerText){
			AddTopicPath(new LinkItem(path, innerText));
		}
Ejemplo n.º 22
0
// メソッド

		/// <summary>
		/// path を元に、適切なコントローラを作成します。
		/// </summary>
		private HatomaruGetAction GetAction(AbsPath path){
			string[] fragments = path.GetFragments(BasePath);
			return new ReputationView(this, path);
		}
Ejemplo n.º 23
0
// プロテクトメソッド


		/// <summary>
		/// リダイレクト応答を返します。
		/// </summary>
		protected HatomaruResponse Redirect(AbsPath path){
			return new RedirectResponse(path, myModel.Manager.IniData.Domain);
		}
Ejemplo n.º 24
0
		public ForbiddenResponse(HatomaruXml source, AbsPath path) : base(source, path, 403, "Forbidden"){}
Ejemplo n.º 25
0
// コンストラクタ
		public MenuAction(HatomaruMenu model, AbsPath path) : base(model, path){
			myPath = myModel.BasePath;
		}
Ejemplo n.º 26
0
// コンストラクタ

		/// <summary>
		/// 最近の日記表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public DiaryIndexViewRecently(DiaryIndex model, AbsPath path) : base(model, path){
			myPath = myModel.BasePath;
		}
Ejemplo n.º 27
0
// コンストラクタ

		/// <summary>
		/// 属性一覧表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public HtmlRefViewAttributeList(HatomaruHtmlRef model, AbsPath path) : base(model, path){
			Data = model;
			myPath = myModel.BasePath.Combine(Id);
		}
Ejemplo n.º 28
0
// コンストラクタ

		/// <summary>
		/// 要素グループ表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public HtmlRefViewElementGroup(HatomaruHtmlRef model, AbsPath path, string id) : base(model, path){
			Data = model;
			myPath = myModel.BasePath.Combine(HtmlRefViewElementGroupList.Id, id);
			myId = id;
		}
Ejemplo n.º 29
0
// コンストラクタ

		/// <summary>
		/// 最近の日記表示のためのアクションのインスタンスを開始します。
		/// </summary>
		public DiaryIndexViewAmazon(DiaryIndex model, AbsPath path) : base(model, path){
			myPath = myModel.BasePath.Combine(Id);
		}
Ejemplo n.º 30
0
// コンストラクタ

		/// <summary>
		/// 個別記事を表示するためのアクションのインスタンスを開始します。
		/// </summary>
		public BbsViewArticle(HatomaruBbs model, AbsPath path, int page) : base(model, path){
			myPageNum = page;
			myPath = myModel.BasePath.Combine(Id, myPageNum.ToString());
		}