* LocalizedText.resx:

* LocalizedText.fr.resx:
* RssFeedsFormatter.cs:
* LocalizedText.Designer.cs: 

* Web.csproj:
* Contact.aspx:
* AOEMail.aspx:
* AssemblyInfo.aspx:
* ReferencedAssemblies.aspx: refactoring

* RssFeeds.cs: Rss feeds in progress

* HomeController.cs: - refactoring
- fixes contact page


* style.css: css for textarea and input

* Index.aspx: Contact & Assembly info in index

* YavscModel.csproj: Rss feeds
This commit is contained in:
Paul Schneider 2015-01-23 17:34:09 +01:00
commit 7694f4d8b3
13 changed files with 261 additions and 63 deletions

View file

@ -44,7 +44,7 @@ namespace Yavsc.Controllers
}
}
public ActionResult ReferencedAssemblies()
public ActionResult AssemblyInfo()
{
AssemblyName[] model = GetType ().Assembly.GetReferencedAssemblies ();
@ -76,17 +76,34 @@ namespace Yavsc.Controllers
return View ();
}
public ActionResult AOEMail (string reason, string body)
public ActionResult Contact (string email, string reason, string body)
{
if (email==null)
ModelState.AddModelError("email","Enter your email");
if (reason==null)
ModelState.AddModelError("reason","Please, fill in a reason");
if (body==null)
ModelState.AddModelError("body","Please, fill in a body");
if (!ModelState.IsValid)
return View ();
// requires valid owner and admin email?
using (System.Net.Mail.MailMessage msg = new MailMessage(owneremail,admail,"Poke : "+reason,body))
if (OwnerEmail == null)
throw new Exception ("No site owner!");
using (System.Net.Mail.MailMessage msg = new MailMessage(email,OwnerEmail,"[Contact] "+reason,body))
{
msg.CC.Add(new MailAddress(Admail));
using (System.Net.Mail.SmtpClient sc = new SmtpClient())
{
sc.Send (msg);
return View ();
ViewData ["Message"] = LocalizedText.Message_sent;
return View (new { reason="", body="" });
}
}
}
}
}

View file

@ -0,0 +1,97 @@
//
// RssFormatter.cs
//
// Author:
// paul <${AuthorEmail}>
//
// Copyright (c) 2015 paul
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Web.Mvc;
using System.Net;
using Yavsc.Model;
using System.Text;
namespace Yavsc.Formatters
{
public class RssFeedsFormatter:SimpleFormatter
{
string doctype = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
public RssFeedsFormatter
() : base ("application/rss+xml")
{
}
private const string dateformat = "ddd, dd MMM yyyy HH:mm:ss K";
public override void WriteToStream (Type type, object value, Stream stream, HttpContentHeaders contentHeaders)
{
RssFeedsChannel feeds = value as RssFeedsChannel;
using (var writer = new StreamWriter (stream)) {
TagBuilder rss = new TagBuilder ("rss");
rss.Attributes.Add ("version", "2.0");
TagBuilder channel = new TagBuilder ("channel");
TagBuilder title = new TagBuilder ("title");
TagBuilder description = new TagBuilder ("description");
TagBuilder lastBuildDate = new TagBuilder ("lastBuildDate");
TagBuilder link = new TagBuilder ("link");
title.InnerHtml = MvcHtmlString.Create (feeds.Title).ToHtmlString ();
description.InnerHtml = MvcHtmlString.Create (feeds.Description).ToHtmlString ();
lastBuildDate.InnerHtml = MvcHtmlString.Create (feeds.LastBuildDate.ToString (dateformat)).ToHtmlString ();
link.InnerHtml = MvcHtmlString.Create (feeds.Link).ToHtmlString ();
StringBuilder sb = new StringBuilder ();
foreach (RssFeedsEntry e in feeds.Entries) {
TagBuilder item = new TagBuilder ("item");
TagBuilder ititle = new TagBuilder ("title");
ititle.InnerHtml = e.Title;
TagBuilder idescription = new TagBuilder ("description");
idescription.InnerHtml = MvcHtmlString.Create (e.Description).ToHtmlString ();
TagBuilder ipubDate = new TagBuilder ("pubDate");
ipubDate.InnerHtml = MvcHtmlString.Create (
e.PubDate.ToString (dateformat)).ToHtmlString ();
TagBuilder ilink = new TagBuilder ("link");
ilink.InnerHtml = MvcHtmlString.Create (e.Link).ToHtmlString ();
item.InnerHtml = ititle.ToString () + "\n" +
idescription.ToString () + "\n" +
ipubDate.ToString () + "\n" +
ilink.ToString () + "\n";
sb.Append (item.ToString () + "\n");
}
channel.InnerHtml = title.ToString () + "\n" +
description.ToString () + "\n" +
lastBuildDate.ToString () + "\n" +
link.ToString () + "\n" +
sb.ToString () + "\n";
rss.InnerHtml = channel.ToString ();
writer.WriteLine (doctype);
writer.Write (rss.ToString ());
}
}
}
}

View file

@ -7,7 +7,13 @@ body {
font-family: 'Arial', cursive;
margin-bottom:3em;
}
textarea {
width:25em;
height:5em;
}
input {
width:25em;
}
main {
background-color: rgba(17,0,23,0.65);
float:left;

View file

@ -1,2 +0,0 @@
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %>

View file

@ -1,9 +1,12 @@
<%@ Page Title="Yavsc - indexe" Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<System.Reflection.AssemblyName>>" MasterPageFile="~/Models/App.master"%>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<p><%= GetType().Assembly.FullName %></p>
<p>
<ul>
<% foreach (System.Reflection.AssemblyName item in Model) { %>
<li><%= item.FullName %></li>
<% } %>
</ul>
</p>
</asp:Content>

View file

@ -0,0 +1,23 @@
<%@ Page Title="Contact" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% using (Html.BeginForm("Contact", "Home")) { %>
<p>
<%= Html.Label("email") %>:
<%= Html.ValidationMessage("email") %><br/>
<%= Html.TextBox("email") %>
</p>
<p>
<%= Html.Label("reason") %>:
<%= Html.ValidationMessage("reason") %><br/>
<%= Html.TextBox("reason") %>
</p>
<p>
<%= Html.Label("body") %>:
<%= Html.ValidationMessage("body") %><br/>
<%= Html.TextArea("body") %>
</p>
<input type="submit">
<% } %>
</asp:Content>

View file

@ -6,6 +6,9 @@
<br/><a href="http://unefenetresurlemonde.over-blog.com/article-34325590.html">Ghost Dog, la Voie du samouraï</a>
</p><div>
<%= Html.ActionLink("Les blogs","Index","Blogs",null, new { @class="actionlink" }) %>
<%= Html.ActionLink("Contact","Contact") %>
<%= Html.ActionLink("Version des librairies","AssemblyInfo") %>
</div>
</asp:Content>

View file

@ -174,6 +174,7 @@
<Compile Include="Helpers\Google\Calendar.cs" />
<Compile Include="Controllers\TemplateException.cs" />
<Compile Include="Formatters\ErrorHtmlFormatter.cs" />
<Compile Include="Formatters\RssFeedsFormatter.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />
@ -204,7 +205,6 @@
<Content Include="Views\Blogs\TitleNotFound.aspx" />
<Content Include="Views\FrontOffice\ProductCategory.aspx" />
<Content Include="Views\FrontOffice\Product.aspx" />
<Content Include="Views\Home\AOEMail.aspx" />
<Content Include="errors\GeneralError.aspx" />
<Content Include="errors\PageNotFound.aspx" />
<Content Include="Views\FrontOffice\Service.aspx" />
@ -246,7 +246,6 @@
<Content Include="Theme\dark\style.css" />
<Content Include="Views\FrontOffice\Estimates.aspx" />
<Content Include="images\pgsql.png" />
<Content Include="Views\Home\ReferencedAssemblies.aspx" />
<Content Include="Catalog.xml" />
<Content Include="RegistrationMail.txt" />
<Content Include="Views\FrontOffice\Writting.ascx" />
@ -631,6 +630,8 @@
<Content Include="Scripts\datepicker-en-GB.js" />
<Content Include="Scripts\datepicker-fr.js" />
<Content Include="Views\Google\GoogleErrorMessage.aspx" />
<Content Include="Views\Home\Contact.aspx" />
<Content Include="Views\Home\AssemblyInfo.aspx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />