* bg.gif:

* asc.gif:
* desc.gif:
* style.css: moved to App_Themes

* style.css:
* bg.gif:
* asc.gif:
* bg.png:
* rect.png:
* asc.png:
* desc.gif:
* jquery-ui.css:
* mdd_styles.css:
* croix.png:
* desc.png:
* style.css:
* jquery-ui.min.css:
* mdd_gripper.png:
* mdd_toolbar.png:
* jquery.timepicker.css:
* mdd_ajax_loader.gif:
* mdd_modal_background.png: moved to /App_Themes

* NpgsqlBlogProvider.cs: * Remove post by id
* Manage collections of entries on a couple (user,title), not a single
  post

* NpgsqlCircleProvider.cs: Fixes the "Match" method.

* IDbModule.cs:
* Edit.aspx:
* Estimates.aspx:
* WorkFlowManager.cs:
* NpgsqlContentProvider.cs: refactoring

* NpgsqlMRPProviders.csproj: new NpgsqlUserName provider

* NpgsqlRoleProvider.cs: simpler init method

* NpgsqlUserNameProvider.cs: impements a UserNameProvider

* MyClass.cs: refactoring from Yavsc.Model

* BlogsController.cs: access control simplified

* FrontOfficeController.cs: Pdf generation made public ni case of
  formatting exception

* mdd_styles.css: Theme -> App_Themes

* style.css: yet another style impact

* AccountController.cs: Fixes the user name modification

* BlogsController.cs: * Fixes the removal process
* On a title and user name, we get collection of posts, not only one.
* Implements an Access on circle

* FrontOfficeController.cs: * implements a new Get method.
* ensure a membership existence before delivering an estimate.

* GoogleController.cs: Fixes the user name modification on a Google
  account

* ErrorHtmlFormatter.cs: nice error message in html (using Markdown
  helper)

* FormatterException.cs: formatter exception exposes error and
  standard output of the process

* TexToPdfFormatter.cs: * generates temporary files in the folder
  returned by Path.GetTempPath()
* throws FormatterException

* Global.asax.cs: new route map:
Blogs/{action}/{user}/{title}
Blog/{user}/{title}
B/{id}
{controller}/{action}/{id}

* App.master: * refactoring: Theme moved to App_Themes
* a link to the logged user's blog
*

* NoLogin.master: refactoring: Theme moved to App_Themes

* Circles.aspx: refactoring : circles now are given as select items

* Login.aspx: fixes the html presentation

* Register.aspx: Fixes a Typo

* Index.aspx: Implements a blog index, due to M&C changes with this
  commit

* RemovePost.aspx: links to the new route to the "RemovePost" action,
  giving it a post id

* RemoveTitle.aspx: fixes a not yet linked page to remove a post
  collection under a given title

* EventPub.aspx: code refactoring

* Writting.ascx: cleans the code

* Web.config: fills the config with new names in the space

* Web.config: configures the new NpgsqlUserNameProvider

* Web.csproj: refactoring and others

* BlogEntryCollection.cs: implement the BlogEntryCollection

* BlogManager.cs: the manager helps to filter on access

* BlogProvider.cs: The title is not unique anymore, and one can modify
  it, post a lot under it, drop all posts under it.
A Post is deleted by id.

* UUBlogEntryCollection.cs: implements a collection of post under a
  given user name.

* UUTBlogEntryCollection.cs: implements a collection of post under a
  given couple (user name, title).

* ListItem.cs: ListItem is declared obsolete in this model, helpers
  can build MVC SelectListItem on data returned by the manager.

* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: autogenerated from xml

* LocalizedText.resx:
* LocalizedText.fr.resx: new labels

* ChangeUserNameProvider.cs: xml doc

* Profile.cs: the UserName property is read only, and comes from
  authentication, to change it, we set a Name and validate it agains
  the "Profile" method

* UserManager.cs: simpler code a init time

* IContentProvider.cs: implements the new IDataProvider interface

* IDataProvider.cs: defines the new IDataProvider interface

* YavscModel.csproj: includes new classes

* UserPosts.aspx: adds a link to remove a post

* UserPost.aspx: now uses the new BlogEntryCollection object
This commit is contained in:
Paul Schneider
2015-08-04 02:10:28 +02:00
parent 294c54099c
commit 3355f9fed0
82 changed files with 1287 additions and 2469 deletions

View File

@ -1,3 +1,10 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* NpgsqlBlogProvider.cs: * Remove post by id
* Manage collections of entries on a couple (user,title), not
a single post
2015-07-15 Paul Schneider <paul@pschneider.fr>
* NpgsqlBlogProvider.csproj: Moves to Mono framework

View File

@ -122,7 +122,13 @@ namespace Npgsql.Web.Blog
/// <param name="postid">Postid.</param>
public override void RemovePost (long postid)
{
throw new NotImplementedException ();
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "delete from blog where _id = @id";
cmd.Parameters.AddWithValue ("id", postid);
cnx.Open ();
cmd.ExecuteNonQuery();
}
}
/// <summary>
/// Comment the specified from, postid and content.
@ -136,7 +142,7 @@ namespace Npgsql.Web.Blog
throw new ArgumentNullException("from");
if (content == null)
throw new ArgumentNullException("content");
bool visible = AutoValidateComment;
bool visible = AutoValidatesComments;
using (NpgsqlConnection cnx=
new NpgsqlConnection(connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand()) {
@ -181,7 +187,7 @@ namespace Npgsql.Web.Blog
/// Gets or sets a value indicating whether this <see cref="Npgsql.Web.Blog.NpgsqlBlogProvider"/> auto validate comment.
/// </summary>
/// <value><c>true</c> if auto validate comment; otherwise, <c>false</c>.</value>
public override bool AutoValidateComment {
public override bool AutoValidatesComments {
get {
return autoValidateComment;
}
@ -273,52 +279,62 @@ namespace Npgsql.Web.Blog
/// <returns>The post.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public override BlogEntry GetPost (string username, string title)
public override UUTBlogEntryCollection GetPost (string username, string title)
{
BlogEntry be = null;
using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand()) {
cmd.CommandText = "select _id,bcontent,modified,posted,visible from blog " +
"where applicationname = :appname and username = :username and title = :title";
cmd.Parameters.AddWithValue ("appname", applicationName);
cmd.Parameters.AddWithValue ("username", username);
cmd.Parameters.AddWithValue ("title", title);
cnx.Open ();
using (NpgsqlDataReader rdr = cmd.ExecuteReader()) {
if (rdr.Read ()) {
be = new BlogEntry ();
be.Title = title;
be.Content = rdr.GetString (rdr.GetOrdinal ("bcontent"));
be.UserName = username;
be.Modified = rdr.GetDateTime (rdr.GetOrdinal ("modified"));
be.Posted = rdr.GetDateTime (rdr.GetOrdinal ("posted"));
be.Visible = rdr.GetBoolean (rdr.GetOrdinal ("visible"));
be.Id = rdr.GetInt64 (rdr.GetOrdinal ("_id"));
}
rdr.Close ();
}
if (be != null) {
using (NpgsqlCommand cmdtags = cnx.CreateCommand ()) {
List<string> tags = new List<string> ();
cmd.CommandText = "select tag.name from tag,tagged where tag._id = tagged.tagid and tagged.postid = :pid";
cmd.Parameters.AddWithValue ("pid", be.Id);
using (NpgsqlDataReader rdrt = cmd.ExecuteReader ()) {
while (rdrt.Read ()) {
tags.Add (rdrt.GetString (0));
}
UUTBlogEntryCollection bec = new UUTBlogEntryCollection (username,title);
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) {
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "select _id,bcontent,modified,posted,visible from blog " +
"where applicationname = :appname and username = :username and title = :title";
cmd.Parameters.AddWithValue ("appname", applicationName);
cmd.Parameters.AddWithValue ("username", username);
cmd.Parameters.AddWithValue ("title", title);
cnx.Open ();
cmd.Prepare ();
using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) {
while (rdr.Read ()) {
BlogEntry be = new BlogEntry ();
be.Title = title;
be.Content = rdr.GetString (rdr.GetOrdinal ("bcontent"));
be.UserName = username;
be.Modified = rdr.GetDateTime (rdr.GetOrdinal ("modified"));
be.Posted = rdr.GetDateTime (rdr.GetOrdinal ("posted"));
be.Visible = rdr.GetBoolean (rdr.GetOrdinal ("visible"));
be.Id = rdr.GetInt64 (rdr.GetOrdinal ("_id"));
bec.Add (be);
}
be.Tags = tags.ToArray ();
rdr.Close ();
}
SetCirclesOn (be);
}
if (bec.Count != 0) {
using (NpgsqlCommand cmdtags = cnx.CreateCommand ()) {
long pid = 0;
cmdtags.CommandText = "select tag.name from tag,tagged where tag._id = tagged.tagid and tagged.postid = :postid";
cmdtags.Parameters.AddWithValue ("postid", NpgsqlTypes.NpgsqlDbType.Bigint, pid);
cmdtags.Prepare ();
foreach (BlogEntry be in bec) {
List<string> tags = new List<string> ();
cmdtags.Parameters ["postid"].Value = be.Id;
using (NpgsqlDataReader rdrt = cmdtags.ExecuteReader ()) {
while (rdrt.Read ()) {
tags.Add (rdrt.GetString (0));
}
}
be.Tags = tags.ToArray ();
}
}
SetCirclesOn (bec);
}
}
return be;
return bec;
}
private void SetCirclesOn(BlogEntry be)
{
List<long> circles = new List<long> ();
using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString))
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmdcircles = cnx.CreateCommand ()) {
cmdcircles.CommandText = "select a.circle_id from blog_access a " +
"where a.post_id = :pid";
@ -326,11 +342,18 @@ namespace Npgsql.Web.Blog
cnx.Open ();
using (NpgsqlDataReader rdr = cmdcircles.ExecuteReader ()) {
while (rdr.Read ()) {
circles.Add ( rdr.GetInt64 (0) );
circles.Add (rdr.GetInt64 (0));
}
}
}
be.AllowedCircles = circles.ToArray();
be.AllowedCircles = circles.ToArray ();
}
private void SetCirclesOn(BlogEntryCollection bec)
{
foreach (BlogEntry be in bec) {
SetCirclesOn (be);
}
}
/// <summary>
/// Post the specified username, title, content and visible.
@ -460,6 +483,7 @@ namespace Npgsql.Web.Blog
if (totalRecords >= firstrec && totalRecords <= lastrec) {
BlogEntry be = new BlogEntry ();
be.Title = rdr.GetString (rdr.GetOrdinal ("title"));
be.Id = rdr.GetInt64 (rdr.GetOrdinal ("_id"));
be.Content = rdr.GetString (rdr.GetOrdinal ("bcontent"));
be.UserName = rdr.GetString (rdr.GetOrdinal ("username"));
be.Posted = rdr.GetDateTime (rdr.GetOrdinal ("posted"));
@ -482,7 +506,7 @@ namespace Npgsql.Web.Blog
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public override void RemovePost (string username, string title)
public override void RemoveTitle (string username, string title)
{
using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand()) {
@ -531,6 +555,7 @@ namespace Npgsql.Web.Blog
while (rdr.Read()) {
if (totalRecords >= firstrec && totalRecords <= lastrec) {
BlogEntry be = new BlogEntry ();
be.Id = rdr.GetInt64 (rdr.GetOrdinal ("_id"));
be.Title = rdr.GetString (rdr.GetOrdinal ("title"));
be.Content = rdr.GetString (rdr.GetOrdinal ("bcontent"));
be.UserName = rdr.GetString (rdr.GetOrdinal ("username"));

View File

@ -1,3 +1,9 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* NpgsqlCircleProvider.cs: Fixes the "Match" method.
* NpgsqlContentProvider.cs: refactoring
2015-07-15 Paul Schneider <paul@pschneider.fr>
* NpgsqlCircleProvider.cs: Makes Circles private, or not

View File

@ -55,7 +55,7 @@ namespace WorkFlowProvider
bool result=false;
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "select count(*)>0 from circle_members where _id = :cid and m.member = :mbr";
cmd.CommandText = "select count(*)>0 from circle_members where circle_id = :cid and member = :mbr";
cmd.Parameters.Add("cid",NpgsqlDbType.Bigint);
cmd.Parameters.AddWithValue("mbr",member);
cnx.Open ();

View File

@ -20,6 +20,8 @@ namespace Yavsc
/// </summary>
public class NpgsqlContentProvider: ProviderBase, IContentProvider
{
/// <summary>
/// Registers the command.
/// </summary>
@ -263,7 +265,7 @@ namespace Yavsc
cnx.Close ();
}
foreach (long id in ids)
ests.Add(GetEstimate(id));
ests.Add(Get(id));
return ests.ToArray();
}
}
@ -306,7 +308,7 @@ namespace Yavsc
rdr.Close ();
}
foreach (long id in ids)
ests.Add(GetEstimate(id));
ests.Add(Get(id));
return ests.ToArray();
}
}
@ -354,7 +356,7 @@ namespace Yavsc
/// </summary>
/// <returns>The estimate.</returns>
/// <param name="estimid">Estimid.</param>
public Estimate GetEstimate (long estimid)
public Estimate Get (long estimid)
{
Estimate est = null;
using (NpgsqlConnection cnx = CreateConnection ()) {
@ -448,7 +450,7 @@ namespace Yavsc
/// Saves the given Estimate object in database.
/// </summary>
/// <param name="estim">the Estimate object.</param>
public void UpdateEstimate (Estimate estim)
public void Update (Estimate estim)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {

View File

@ -1,3 +1,11 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* NpgsqlMRPProviders.csproj: new NpgsqlUserName provider
* NpgsqlRoleProvider.cs: simpler init method
* NpgsqlUserNameProvider.cs: impements a UserNameProvider
2015-08-01 Paul Schneider <paul@pschneider.fr>
* NpgsqlMembershipProvider.cs: Fixes the membership update.

View File

@ -36,6 +36,7 @@
<Compile Include="NpgsqlRoleProvider.cs" />
<Compile Include="NpgsqlProfileProvider.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="NpgsqlUserNameProvider.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Collections.Specialized;
namespace Npgsql.Web
{
@ -38,40 +38,19 @@ namespace Npgsql.Web
/// </summary>
/// <param name="iname">Iname.</param>
/// <param name="config">Config.</param>
public override void Initialize (string iname, System.Collections.Specialized.NameValueCollection config)
public override void Initialize (string iname, NameValueCollection config)
{
try {
name = iname ?? config ["name"];
connectionStringName = config ["connectionStringName"] ?? connectionStringName;
applicationName = config ["applicationName"] ?? applicationName;
if (applicationName.Length > 250)
throw new ProviderException ("The maximum length for an application name is 250 characters.");
var cs = ConfigurationManager.ConnectionStrings [connectionStringName];
if (cs == null || string.IsNullOrEmpty (cs.ConnectionString)) {
throw new ProviderException (
string.Format ("The role provider connection string, '{0}', is not defined.", connectionStringName));
}
connectionString = ConfigurationManager.ConnectionStrings [connectionStringName].ConnectionString;
if (string.IsNullOrEmpty (connectionString))
throw new ConfigurationErrorsException (
string.Format (
"The connection string for the given name ({0})" +
"must be specified in the <connectionStrings>" +
"configuration bloc. Aborting.", connectionStringName)
);
} catch (Exception ex) {
var message = "Error initializing the role configuration settings";
throw new ProviderException (message, ex);
}
// get the
// - application name
// - connection string name
// - the connection string from its name
string cnxName = config ["connectionStringName"];
connectionString = ConfigurationManager.ConnectionStrings [cnxName].ConnectionString;
config.Remove ("connectionStringName");
applicationName = config ["applicationName"];
config.Remove ("applicationName");
base.Initialize (iname, config);
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Adds the users to roles.

View File

@ -18,34 +18,86 @@
//
// 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.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using Npgsql;
using NpgsqlTypes;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;
namespace Npgsql.Web
namespace Npgsql.Web.RolesAndMembers
{
using Yavsc.Model.RolesAndMembers;
/// <summary>
/// Npgsql user name provider.
/// </summary>
public class NpgsqlUserNameProvider: ChangeUserNameProvider {
private string applicationName;
private string connectionString;
/// <summary>
/// Initialize the specified iname and config.
/// </summary>
/// <param name="iname">Iname.</param>
/// <param name="config">Config.</param>
public override void Initialize (string iname, NameValueCollection config)
{
// get the
// - application name
// - connection string name
// - the connection string from its name
string cnxName = config ["connectionStringName"];
connectionString = ConfigurationManager.ConnectionStrings [cnxName].ConnectionString;
config.Remove ("connectionStringName");
applicationName = config ["applicationName"];
config.Remove ("applicationName");
base.Initialize (iname, config);
}
private string GetConfigValue (string configValue, string defaultValue)
{
if (String.IsNullOrEmpty (configValue))
return defaultValue;
return configValue;
}
#region implemented abstract members of ChangeUserNameProvider
/// <summary>
/// Changes the name.
/// </summary>
/// <param name="oldName">Old name.</param>
/// <param name="newName">New name.</param>
public override void ChangeName (string oldName, string newName)
{
throw new NotImplementedException ();
using (NpgsqlConnection conn = new NpgsqlConnection (connectionString)) {
conn.Open ();
using (NpgsqlCommand cmd = new NpgsqlCommand (
"UPDATE users set " +
"username = :uname where username = :oname" +
" AND ApplicationName = :appname ", conn)) {
cmd.Parameters.AddWithValue ("uname", newName);
cmd.Parameters.AddWithValue ("oname", oldName);
cmd.Parameters.AddWithValue ("appname", this.applicationName);
cmd.ExecuteNonQuery ();
}
}
}
/// <summary>
/// Determines whether this instance is name available the specified name.
/// </summary>
/// <returns>true</returns>
/// <c>false</c>
/// <param name="name">Name.</param>
public override bool IsNameAvailable (string name)
{
throw new NotImplementedException ();
using (NpgsqlConnection conn = new NpgsqlConnection (connectionString)) {
conn.Open ();
using (NpgsqlCommand cmd = new NpgsqlCommand (
"SELECT count(*)>0 FROM users " +
"WHERE username = :uname AND ApplicationName = :appname", conn)) {
cmd.Parameters.AddWithValue ("uname", name);
cmd.Parameters.AddWithValue ("appname", this.applicationName);
return (bool) cmd.ExecuteScalar ();
}
}
}
#endregion
}

View File

@ -1,3 +1,7 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* MyClass.cs: refactoring from Yavsc.Model
2015-07-15 Paul Schneider <paul@pschneider.fr>
* fortune.csproj: Moves to Mono framework

View File

@ -12,7 +12,7 @@ namespace fortune
public string Body{ get; set; }
}
public class MyClass : IModule
public class MyClass : IDbModule
{
public MyClass ()
{

View File

@ -6,6 +6,7 @@ using System.Web.Security;
using System.Web.Http;
using Npgsql.Web.Blog;
using Yavsc.Model.Blogs;
using System.IO;
namespace Yavsc.ApiControllers
{
@ -34,37 +35,26 @@ namespace Yavsc.ApiControllers
/// <param name="postid">Postid.</param>
/// <param name="tag">Tag.</param>
public long Tag (long postid,string tag) {
BlogEntry e = BlogManager.GetPost (postid);
if (!Roles.IsUserInRole ("Admin")) {
string rguser = Membership.GetUser ().UserName;
if (rguser != e.UserName) {
throw new AccessViolationException (
string.Format (
"Vous n'avez pas le droit de tagger des billets du Blog de {0}",
e.UserName));
}
}
BlogManager.GetForEditing (postid);
return BlogManager.Tag (postid, tag);
}
/// <summary>
/// Removes the post.
/// </summary>
/// <param name="user">User.</param>
/// <param name="title">Title.</param>
public void RemovePost(string user, string title) {
BlogEntry e = BlogManager.GetPost (user, title);
if (e == null) {
throw new KeyNotFoundException (
string.Format("Aucun post portant le titre \"{0}\" pour l'utilisateur {1}",
title, user));
}
BlogManager.RemovePost (user, title);
[Authorize]
public void RemoveTitle(string user, string title) {
BlogManager.CheckAuthCanEdit (user,title);
BlogManager.RemoveTitle (user, title);
}
/// <summary>
/// Removes the tag.
/// </summary>
/// <param name="tagid">Tagid.</param>
public void RemoveTag(long tagid) {
throw new NotImplementedException ();
}
}

View File

@ -16,6 +16,8 @@ using System.IO;
namespace Yavsc.ApiControllers
{
/// <summary>
/// Front office controller.
/// </summary>
@ -58,18 +60,6 @@ namespace Yavsc.ApiControllers
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie);
}
/// <summary>
/// Authorization denied.
/// </summary>
public class AuthorizationDenied : HttpRequestException {
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.ApiControllers.FrontOfficeController+AuthorizationDenied"/> class.
/// </summary>
/// <param name="msg">Message.</param>
public AuthorizationDenied(string msg) : base(msg)
{
}
}
/// <summary>
/// Gets the estimate.
@ -80,7 +70,7 @@ namespace Yavsc.ApiControllers
[HttpGet]
public Estimate GetEstimate (long id)
{
Estimate est = wfmgr.ContentProvider.GetEstimate (id);
Estimate est = wfmgr.ContentProvider.Get (id);
string username = Membership.GetUser ().UserName;
if (est.Client != username)
if (!Roles.IsUserInRole("Admin"))
@ -135,7 +125,7 @@ namespace Yavsc.ApiControllers
tmpe.Session.Add ("from", prpro);
tmpe.Session.Add ("to", prcli);
tmpe.Session.Add ("efrom", Membership.GetUser (e.Responsible).Email);
tmpe.Session.Add ("efrom", Membership.GetUser (e.Client).Email);
tmpe.Session.Add ("eto", Membership.GetUser (e.Client).Email);
tmpe.Init ();
return tmpe.TransformText ();
}
@ -173,15 +163,29 @@ namespace Yavsc.ApiControllers
};
var memPdf = new MemoryStream ();
HttpResponseMessage result = new HttpResponseMessage ();
try {
new TexToPdfFormatter ().WriteToStream (
typeof(string), texest, memPdf,null);
memPdf.Position = 0;
var sr = new StreamReader(memPdf);
var str = sr.ReadToEnd();
result.Content = new StringContent (str);
TexToPdfFormatter.SetFileName (result.Content.Headers, "estimate-" + id.ToString ());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/x-tex");
}
catch (FormatterException ex) {
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string), ex.Message+"\n\n"+ex.Output+"\n\n"+ex.Error,
new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
LocalizedText.InternalServerError))
};
}
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(memPdf.GetBuffer())
};
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue ("attachment") {
FileName = String.Format (
"Estimation-{0}.pdf",
id)
};
return result;
}

View File

@ -10,7 +10,7 @@ div.mdd_modal
z-index:1000;
display:none;
font-size:10pt;
background-image:url(/Theme/md/mdd_modal_background.png);
background-image:url(/App_Themes/md/mdd_modal_background.png);
}
div.mdd_modal_frame
{
@ -64,7 +64,7 @@ div.mdd_modal_content
div.mdd_ajax_loader
{
background-position: center center;
background-image: url(/Theme/md/mdd_ajax_loader.gif);
background-image: url(/App_Themes/md/mdd_ajax_loader.gif);
background-repeat: no-repeat;
width:100%;
height:200px;
@ -119,7 +119,7 @@ div.mdd_toolbar li
div.mdd_toolbar a.mdd_button
{
background-image:url(/Theme/md/mdd_toolbar.png);
background-image:url(/App_Themes/md/mdd_toolbar.png);
width:20px;
height:20px;
display:block;
@ -184,7 +184,7 @@ textarea.mdd_editor
div.mdd_resizer
{
background:#f8f8f8;
background-image:url("/Theme/md/mdd_gripper.png");
background-image:url("/App_Themes/md/mdd_gripper.png");
background-position:center center;
background-repeat:no-repeat;
width:100%;

View File

@ -5,8 +5,8 @@ body {
background-repeat: no-repeat;
color: #D0FFD0;
font-family: 'Arial', cursive;
padding: .5em;
margin-bottom:2.8em;
padding: 0em;
margin-bottom:3em;
}
textarea {
@ -20,10 +20,8 @@ input, textarea, checkbox {
}
main {
background-color: rgba(17,0,23,0.65);
float:left;
}
margin:1em;
}
fieldset {
background-color: rgba(32,16,16,0.8);
border-radius:5px; border: solid 1px #000060;
@ -46,7 +44,6 @@ footer {
z-index:-1;
font-size: smaller;
}
.thanks {
max-width: 10%;
text-align: center;
@ -59,12 +56,14 @@ footer {
#logo {
float: left;
max-height: 25%;
max-width: 25%;
}
.panel,.bshpanel,aside {
background-color: rgba(32,16,16,0.8);
border-radius:5px; border: solid 1px #000060;
float: right;
float: left;
margin:.5em;
padding: .5em;
}
@ -72,23 +71,29 @@ footer {
.bsh { float: right; }
#login {
position: fixed;
margin:0em;
padding:0em;
top:0;
right:0;
background-color:rgba(16,16,0,0.8);
justify-content: space-around;
text-align: center;
max-width:40%;
font-size:75%;
}
#login img { max-height:5em; max-width:5em; }
header {
background-color:rgba(16,16,0,0.8);
top:0;
left:0;
right:0;
margin:0em;
padding:0em;
text-align: center;
max-width:55%;
}
h1 img { vertical-align: text-top; }
h1 img { vertical-align: text-top; }
a {
text-decoration: none;
@ -135,7 +140,15 @@ label {
.blogtitle {
display:inline;
}
.blogpost {
display:block;
margin:1em;
padding:1em;
border: solid 2px blue;
background-color: #090609;
color: #aaa;
border-radius:5px;
}
.contenu {
padding-left: 20px;
}
@ -158,14 +171,13 @@ ul.preview li:nth-child(n) {
.actionlink {
color: #B0B080;
border: solid 1px rgb(128,128,128);
border-radius:5px;
border-radius: 5px;
background-color:rgba(0,0,32,0.8);
font-size:large;
cursor: pointer;
font-family: 'Arial', cursive;
}
input, select {
input, select {
color: #B0B080;
border: solid 1px rgb(128,128,128);
border-radius:5px;
@ -193,46 +205,30 @@ a.actionlink img { top:4px; }
max-height: 64px;
}
.hidden {
display:none;
}
.shoh { display:inline; }
.hiduh {
display:none;
}
.shoh:hover {
background-color: rgba(0,60,40,.3);
border: solid rgb(256,256,0);
}
.shoh:hover + .hiduh {
display:block; position:absolute; left:20px; right:20px;
background-color: rgb(0,0,40); border: solid rgb(256,256,0);
}
.comment {
border-radius:25px;
border-width:1px;
border-style: solid;
border-style: solid;
border-color:rgb(0,64,0);
font-size: smaller;
}
.hidcom {
display:none; position:fixed; z-index:2;
.onhover {
display:none;
position: absolute;
}
.ohafter:hover + .onhover, .ohinside:hover > .onhover {
display:block;
z-index:2;
padding:5px; margin:5px;
background-color: rgba(0,0,40,.8);
}
a.actionlink:hover + .hidcom {
display:block;
}
.input-validation-error { border: solid 1px red; }
.field-validation-error { color: red; }
.c2 { font-size: small; font-style: italic; }
.c3 { font-size: x-small; font-style: italic; }
@media print {
body {background-color:white;color:black;}
header,footer,.postcomment,.actionlink,.metablog,#login{ display:none;}
@ -240,26 +236,28 @@ a.actionlink:hover + .hidcom {
@media all and (min-width: 641px) {
.bshpanel { display:block; }
.bsh { display: none; }
.c3 { display:initial; }
.c3-alt { display:none; }
}
@media all and (max-width: 640px) {
.bshpanel { cursor:zoom-in; }
.bshd:hover > .bshpanel {
display: block;
}
.bshd:hover > .bsh {
display: none;
}
footer {
font-size: x-small;
}
body { font-size: smaller; }
.c2 { display:initial; }
.c2-alt { display:none; }
.c3 { display:none; }
.c3-alt { display:initial; }
}
@media all and (max-width: 350px) {
footer { font-size: xx-small; }
.c2 { display:none; }
.c2-alt { display:initial; }
}
}

View File

@ -1,3 +1,110 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* bg.gif:
* asc.gif:
* desc.gif:
* style.css: moved to App_Themes
* style.css:
* bg.gif:
* asc.gif:
* bg.png:
* rect.png:
* asc.png:
* desc.gif:
* jquery-ui.css:
* mdd_styles.css:
* croix.png:
* desc.png:
* style.css:
* jquery-ui.min.css:
* mdd_gripper.png:
* mdd_toolbar.png:
* jquery.timepicker.css:
* mdd_ajax_loader.gif:
* mdd_modal_background.png: moved to /App_Themes
* BlogsController.cs: access control simplified
* FrontOfficeController.cs: Pdf generation made public ni case
of formatting exception
* mdd_styles.css: Theme -> App_Themes
* style.css: yet another style impact
* AccountController.cs: Fixes the user name modification
* BlogsController.cs: * Fixes the removal process
* On a title and user name, we get collection of posts, not
only one.
* Implements an Access on circle
* FrontOfficeController.cs: * implements a new Get method.
* ensure a membership existence before delivering an estimate.
* GoogleController.cs: Fixes the user name modification on a
Google account
* ErrorHtmlFormatter.cs: nice error message in html (using
Markdown helper)
* FormatterException.cs: formatter exception exposes error and
standard output of the process
* TexToPdfFormatter.cs: * generates temporary files in the
folder returned by Path.GetTempPath()
* throws FormatterException
* Global.asax.cs: new route map:
Blogs/{action}/{user}/{title}
Blog/{user}/{title}
B/{id}
{controller}/{action}/{id}
* App.master: * refactoring: Theme moved to App_Themes
* a link to the logged user's blog
*
* NoLogin.master: refactoring: Theme moved to App_Themes
* Circles.aspx: refactoring : circles now are given as select
items
* Login.aspx: fixes the html presentation
* Register.aspx: Fixes a Typo
* Edit.aspx:
* Estimates.aspx: refactoring
* Index.aspx: Implements a blog index, due to M&C changes with
this commit
* RemovePost.aspx: links to the new route to the "RemovePost"
action, giving it a post id
* RemoveTitle.aspx: fixes a not yet linked page to remove a
post collection under a given title
* EventPub.aspx: code refactoring
* Writting.ascx: cleans the code
* Web.config: fills the config with new names in the space
* Web.config: configures the new NpgsqlUserNameProvider
* Web.csproj: refactoring and others
* UserPosts.aspx: adds a link to remove a post
* UserPost.aspx: now uses the new BlogEntryCollection object
2015-07-23 Paul Schneider <paul@pschneider.fr>
* Web.config: Trace may be enabled, as long it is in local

View File

@ -219,15 +219,13 @@ namespace Yavsc.Controllers
/// <param name="user">User name.</param>
[Authorize]
[HttpGet]
public ActionResult Profile (string user)
public ActionResult Profile (string id)
{
ViewData ["ProfileUserName"] = user;
string logdu = Membership.GetUser ().UserName;
ViewData ["UserName"] = logdu;
if (user == null)
user = logdu;
Profile model = new Profile (ProfileBase.Create (user));
model.RememberMe = FormsAuthentication.GetAuthCookie (user, true) == null;
if (id == null)
id = Membership.GetUser ().UserName;
ViewData ["UserName"] = id;
Profile model = new Profile (ProfileBase.Create (id));
model.RememberMe = FormsAuthentication.GetAuthCookie (id, true) == null;
return View (model);
}
@ -239,14 +237,14 @@ namespace Yavsc.Controllers
/// <param name="AvatarFile">Avatar file.</param>
[Authorize]
[HttpPost]
public ActionResult Profile (string user, Profile model, HttpPostedFileBase AvatarFile)
public ActionResult Profile (string id, Profile model, HttpPostedFileBase AvatarFile)
{
// ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash"
string logdu = Membership.GetUser ().UserName;
ViewData ["UserName"] = logdu;
bool editsMyProfile = (user == logdu);
if (!editsMyProfile)
ViewData ["UserName"] = id;
bool editsMyName = (id != model.Name);
if (!editsMyName)
if (!Roles.IsUserInRole ("Admin"))
if (!Roles.IsUserInRole ("FrontOffice"))
throw new UnauthorizedAccessException ("Your are not authorized to modify this profile");
@ -257,9 +255,9 @@ namespace Yavsc.Controllers
// else invalidate the model
if (AvatarFile.ContentType == "image/png") {
string avdir = Server.MapPath (AvatarDir);
string avpath = Path.Combine (avdir, user + ".png");
string avpath = Path.Combine (avdir, id + ".png");
AvatarFile.SaveAs (avpath);
model.avatar = Request.Url.Scheme + "://" + Request.Url.Authority + AvatarDir.Substring (1) + "/" + user + ".png";
model.avatar = Request.Url.Scheme + "://" + Request.Url.Authority + AvatarDir.Substring (1) + "/" + id + ".png";
} else
ModelState.AddModelError ("Avatar",
string.Format ("Image type {0} is not supported (suported formats : {1})",
@ -270,7 +268,8 @@ namespace Yavsc.Controllers
if (cAvat != null) if (model.avatar == null) model.avatar = cAvat;
*/
if (ModelState.IsValid) {
ProfileBase prf = ProfileBase .Create (model.UserName);
ProfileBase prf = ProfileBase .Create (id);
prf.SetPropertyValue ("Name", model.Name);
prf.SetPropertyValue ("BlogVisible", model.BlogVisible);
prf.SetPropertyValue ("BlogTitle", model.BlogTitle);
if (AvatarFile != null) {
@ -295,10 +294,11 @@ namespace Yavsc.Controllers
prf.SetPropertyValue ("gcalid", model.GoogleCalendar);
prf.Save ();
// only do the following if this profile belongs to current user
if (editsMyProfile)
FormsAuthentication.SetAuthCookie (user, model.RememberMe);
ViewData ["Message"] = "Profile enregistré"+((editsMyProfile)?", cookie modifié.":"");
if (editsMyName) {
UserManager.ChangeName (id, model.Name);
FormsAuthentication.SetAuthCookie (model.Name, model.RememberMe);
}
ViewData ["Message"] = "Profile enregistré"+((editsMyName)?", nom public inclus.":"");
}
return View (model);
}
@ -309,7 +309,10 @@ namespace Yavsc.Controllers
public ActionResult Circles ()
{
string user = Membership.GetUser ().UserName;
ViewData["Circles"] = CircleManager.DefaultProvider.List (user);
ViewData["Circles"] = CircleManager.DefaultProvider.List (user).Select (x => new SelectListItem {
Value = x.Value,
Text = x.Text
});;
return View ();
}
/// <summary>

View File

@ -39,6 +39,7 @@ namespace Yavsc.Controllers
get { return avatarDir; }
set { avatarDir = value; }
}
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Controllers.BlogsController"/> class.
/// </summary>
@ -50,6 +51,7 @@ namespace Yavsc.Controllers
defaultAvatar = defaultAvatarSpec [0];
defaultAvatarMimetype = defaultAvatarSpec [1];
}
/// <summary>
/// Index the specified user, title, pageIndex and pageSize.
/// </summary>
@ -57,14 +59,14 @@ namespace Yavsc.Controllers
/// <param name="title">Title.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
public ActionResult Index (string user = null, string title = null, int pageIndex=0, int pageSize=10)
public ActionResult Index (string user = null, string title = null, int pageIndex = 0, int pageSize = 10)
{
if (string.IsNullOrEmpty (user)) {
return BlogList (pageIndex, pageSize);
} else {
MembershipUser u = null;
if (Membership.FindUsersByName (user) != null)
u= Membership.GetUser (user, false);
if (Membership.FindUsersByName (user) != null)
u = Membership.GetUser (user, false);
if (u == null) {
ModelState.AddModelError ("UserName",
string.Format ("Utilisateur inconu : {0}", user));
@ -72,12 +74,11 @@ namespace Yavsc.Controllers
} else {
if (string.IsNullOrEmpty (title))
return UserPosts (user, pageIndex, pageSize);
return UserPost (user, title);
return UserPost (user, title, pageIndex, pageSize);
}
}
}
/// <summary>
/// Blogs the list.
/// </summary>
@ -88,11 +89,11 @@ namespace Yavsc.Controllers
{
ViewData ["SiteName"] = sitename;
int totalRecords;
BlogEntryCollection bs = BlogManager.LastPosts (pageIndex, pageSize, out totalRecords);
var bs = BlogManager.LastPosts (pageIndex, pageSize, out totalRecords);
ViewData ["RecordCount"] = totalRecords;
ViewData ["PageSize"] = pageSize;
ViewData ["pageSize"] = pageSize;
ViewData ["PageIndex"] = pageIndex;
return View ("Index", bs);
return View ("Index", new BlogEntryCollection(bs) );
}
/// <summary>
@ -111,6 +112,8 @@ namespace Yavsc.Controllers
ViewData ["SiteName"] = sitename;
ViewData ["BlogUser"] = user;
string readersName = null;
ViewData ["PageIndex"] = pageIndex;
ViewData ["pageSize"] = pageSize;
// displays invisible items when the logged user is also the author
if (u != null) {
if (u.UserName == user || Roles.IsUserInRole ("Admin"))
@ -118,106 +121,135 @@ namespace Yavsc.Controllers
readersName = u.UserName;
}
// find entries
BlogEntryCollection c = BlogManager.FindPost (readersName, user, sf, pageIndex, pageSize, out tr);
BlogEntryCollection c =
BlogManager.FindPost (readersName, user, sf, pageIndex, pageSize, out tr);
// Get author's meta data
Profile bupr = new Profile (ProfileBase.Create (user));
ViewData ["BlogUserProfile"] = bupr;
// Inform of listing meta data
ViewData ["BlogTitle"] = bupr.BlogTitle;
ViewData ["Avatar"] = bupr.avatar;
ViewData ["PageIndex"] = pageIndex;
ViewData ["PageSize"] = pageSize;
ViewData ["RecordCount"] = tr;
return View ("UserPosts", c);
UUBlogEntryCollection uuc = new UUBlogEntryCollection (user, c);
if (uuc.ConcernsAUniqueTitle)
if (uuc.Count>0)
return View ("UserPost", new UUTBlogEntryCollection(uuc.UserName,
uuc[0].Title,uuc));
return View ("Index", uuc);
}
/// <summary>
/// Removes the comment.
/// </summary>
/// <returns>The comment.</returns>
/// <param name="cmtid">Cmtid.</param>
[Authorize]
public ActionResult RemoveComment(long cmtid)
public ActionResult RemoveComment (long cmtid)
{
long postid = BlogManager.RemoveComment (cmtid);
return UserPost (postid);
return GetPost (postid);
}
private ActionResult UserPost (long id)
/// <summary>
/// Returns the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="id">Identifier.</param>
public ActionResult GetPost (long id)
{
ViewData ["PostId"] = id;
BlogEntry e = BlogManager.GetPost (id);
return UserPost (e);
}
private ActionResult UserPost (BlogEntry e)
{
if (e == null)
return View ("TitleNotFound");
Profile pr = new Profile (ProfileBase.Create (e.UserName));
if (pr==null)
ViewData ["id"] = id;
BlogEntry e = BlogManager.GetForReading (id);
UUTBlogEntryCollection c = new UUTBlogEntryCollection (e.UserName,e.Title);
c.Add (e);
ViewData ["user"] = c.UserName;
ViewData ["title"] = c.Title;
Profile pr = new Profile (ProfileBase.Create (c.UserName));
if (pr == null)
// the owner's profile must exist
// in order to publish its bills
return View ("NotAuthorized");
ViewData ["BlogUserProfile"] = pr;
ViewData ["BlogTitle"] = pr.BlogTitle;
ViewData ["Avatar"] = pr.avatar;
MembershipUser u = Membership.GetUser ();
if (u != null)
ViewData ["UserName"] = u.UserName;
if (!e.Visible || !pr.BlogVisible) {
// only deliver to admins or owner
if (u == null)
ViewData ["BlogTitle"] = pr.BlogTitle;
return View (c);
}
/// <summary>
/// Users the post.
/// Assume that :
/// * bec.Count > O
/// * bec.All(x=>x.UserName == bec[0].UserName) ;
/// </summary>
/// <returns>The post.</returns>
/// <param name="bec">Bec.</param>
private ActionResult UserPosts (UUTBlogEntryCollection bec)
{
if (ModelState.IsValid)
if (bec.Count > 0) {
Profile pr = new Profile (ProfileBase.Create (bec.UserName));
if (pr == null)
// the owner's profile must exist
// in order to publish its bills
return View ("NotAuthorized");
else {
if (u.UserName != e.UserName)
if (!Roles.IsUserInRole (u.UserName, "Admin"))
ViewData ["BlogUserProfile"] = pr;
ViewData ["Avatar"] = pr.avatar;
ViewData ["BlogTitle"] = pr.BlogTitle;
MembershipUser u = Membership.GetUser ();
if (u != null)
ViewData ["UserName"] = u.UserName;
if (!pr.BlogVisible) {
// only deliver to admins or owner
if (u == null)
return View ("NotAuthorized");
else {
if (u.UserName != bec.UserName)
if (!Roles.IsUserInRole (u.UserName, "Admin"))
return View ("NotAuthorized");
}
}
} else {
if (!CanViewPost(e,u))
return View ("NotAuthorized");
}
ViewData ["Comments"] = BlogManager.GetComments (e.Id);
return View ("UserPost", e);
}
private bool CanViewPost (BlogEntry e, MembershipUser u=null) {
if (e.AllowedCircles!=null && e.AllowedCircles.Length > 0) {
// only deliver to admins, owner, or specified circle memebers
if (u == null)
return false;
if (u.UserName != e.UserName)
if (!Roles.IsUserInRole (u.UserName, "Admin"))
if (!CircleManager.DefaultProvider.Matches (e.AllowedCircles, u.UserName))
return false;
}
return true;
return View (BlogManager.FilterOnReadAccess(bec as UUTBlogEntryCollection));
}
/// <summary>
/// Users the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="user">User.</param>
/// <param name="title">Title.</param>
public ActionResult UserPost (string user, string title)
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
public ActionResult UserPost (string user, string title, int pageIndex = 0, int pageSize = 10)
{
ViewData ["BlogUser"] = user;
ViewData ["PostTitle"] = title;
int postid = 0;
if (string.IsNullOrEmpty (title)) {
if (int.TryParse (user, out postid)) {
return UserPost (BlogManager.GetPost (postid));
}
}
return UserPost (BlogManager.GetPost (user, title));
ViewData ["user"] = user;
ViewData ["title"] = title;
ViewData ["PageIndex"] = pageIndex;
ViewData ["pageSize"] = pageSize;
var pb = ProfileBase.Create (user);
if (pb == null)
// the owner's profile must exist
// in order to publish its bills
return View ("NotAuthorized");
Profile pr = new Profile (pb);
ViewData ["BlogUserProfile"] = pr;
ViewData ["Avatar"] = pr.avatar;
ViewData ["BlogTitle"] = pr.BlogTitle;
UUTBlogEntryCollection c = new UUTBlogEntryCollection (user, title);
c.AddRange ( BlogManager.FilterOnReadAccess (BlogManager.GetPost (user, title)));
return View ("UserPost",c);
}
/// <summary>
/// Post the specified user and title.
/// </summary>
/// <param name="user">User.</param>
/// <param name="title">Title.</param>
[Authorize,
ValidateInput(false)]
ValidateInput (false)]
public ActionResult Post (string user, string title)
{
ViewData ["BlogUser"] = user;
ViewData ["PostTitle"] = title;
ViewData ["SiteName"] = sitename;
string un = Membership.GetUser ().UserName;
if (String.IsNullOrEmpty (user))
@ -225,7 +257,7 @@ namespace Yavsc.Controllers
if (String.IsNullOrEmpty (title))
title = "";
ViewData ["UserName"] = un;
ViewData["AllowedCircles"] = CircleManager.DefaultProvider.List (Membership.GetUser ().UserName).Select (x => new SelectListItem {
ViewData ["AllowedCircles"] = CircleManager.DefaultProvider.List (Membership.GetUser ().UserName).Select (x => new SelectListItem {
Value = x.Value,
Text = x.Text
});
@ -239,57 +271,45 @@ namespace Yavsc.Controllers
/// <returns>The edit.</returns>
/// <param name="model">Model.</param>
[Authorize,
ValidateInput(false)]
ValidateInput (false)]
public ActionResult ValidateEdit (BlogEntry model)
{
ViewData ["SiteName"] = sitename;
ViewData ["BlogUser"] = Membership.GetUser ().UserName;
if (ModelState.IsValid) {
if (model.Id != 0)
BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible, model.AllowedCircles);
else
if (model.Id != 0)
BlogManager.UpdatePost (model.Id, model.Title, model.Content, model.Visible, model.AllowedCircles);
else
model.Id = BlogManager.Post (model.UserName, model.Title, model.Content, model.Visible, model.AllowedCircles);
return RedirectToAction ("UserPost",new { user = model.UserName, title = model.Title });
return RedirectToAction ("UserPosts", new { user = model.UserName, title = model.Title });
}
return View ("Edit", model);
}
/// <summary>
/// Edit the specified model.
/// Edit the specified bill
/// </summary>
/// <param name="model">Model.</param>
[Authorize,
ValidateInput(false)]
public ActionResult Edit (BlogEntry model)
/// <param name="id">Identifier.</param>
[Authorize, ValidateInput (false)]
public ActionResult Edit (long id)
{
string user = Membership.GetUser ().UserName;
Profile pr = new Profile (HttpContext.Profile);
ViewData ["BlogTitle"] = pr.BlogTitle;
ViewData ["UserName"] = user;
if (model.UserName == null) {
model.UserName = user;
}
BlogEntry e = BlogManager.GetPost (model.UserName, model.Title);
if (e != null) {
if (e.UserName != user) {
return View ("NotAuthorized");
}
model = e;
ModelState.Clear ();
TryValidateModel (model);
}
if (model.AllowedCircles==null)
model.AllowedCircles = new long[0];
ViewData["AllowedCircles"] = CircleManager.DefaultProvider.List (Membership.GetUser ().UserName).Select (x => new SelectListItem {
BlogEntry e = BlogManager.GetForEditing (id);
string user = Membership.GetUser ().UserName;
Profile pr = new Profile (ProfileBase.Create(e.UserName));
ViewData ["BlogTitle"] = pr.BlogTitle;
ViewData ["LOGIN"] = user;
// Populates the circles combo items
if (e.AllowedCircles == null)
e.AllowedCircles = new long[0];
ViewData ["AllowedCircles"] = CircleManager.DefaultProvider.List (Membership.GetUser ().UserName).Select (x => new SelectListItem {
Value = x.Value,
Text = x.Text,
Selected = model.AllowedCircles.Contains(long.Parse(x.Value))
Selected = e.AllowedCircles.Contains (long.Parse (x.Value))
});
return View (model);
return View (e);
}
/// <summary>
@ -297,17 +317,19 @@ namespace Yavsc.Controllers
/// </summary>
/// <param name="model">Model.</param>
[Authorize]
public ActionResult Comment (Comment model) {
public ActionResult Comment (Comment model)
{
string username = Membership.GetUser ().UserName;
ViewData ["SiteName"] = sitename;
if (ModelState.IsValid) {
BlogManager.Comment(username, model.PostId, model.CommentText, model.Visible);
return UserPost (model.PostId);
BlogManager.Comment (username, model.PostId, model.CommentText, model.Visible);
return GetPost (model.PostId);
}
return UserPost (model.PostId);
return GetPost (model.PostId);
}
string defaultAvatar;
/// <summary>
/// Avatar the specified user.
/// </summary>
@ -316,20 +338,20 @@ namespace Yavsc.Controllers
public ActionResult Avatar (string user)
{
ProfileBase pr = ProfileBase.Create (user);
string avpath = (string) pr.GetPropertyValue ("avatar");
if (avpath==null) {
string avpath = (string)pr.GetPropertyValue ("avatar");
if (avpath == null) {
FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar));
return File (fia.OpenRead (), defaultAvatarMimetype);
}
if (avpath.StartsWith ("~/")) {
}
WebRequest wr = WebRequest.Create(avpath);
WebRequest wr = WebRequest.Create (avpath);
FileContentResult res;
using (WebResponse resp = wr.GetResponse ()) {
using (Stream str = resp.GetResponseStream ()) {
byte [] content = new byte[str.Length];
str.Read (content, 0, (int) str.Length);
byte[] content = new byte[str.Length];
str.Read (content, 0, (int)str.Length);
res = File (content, resp.ContentType);
wr.Abort ();
return res;
@ -347,26 +369,46 @@ namespace Yavsc.Controllers
/// <param name="returnUrl">Return URL.</param>
/// <param name="confirm">If set to <c>true</c> confirm.</param>
[Authorize]
public ActionResult RemovePost (string user, string title, string returnUrl, bool confirm=false)
public ActionResult RemoveTitle (string user, string title, string returnUrl, bool confirm = false)
{
if (returnUrl == null)
if (Request.UrlReferrer!=null)
if (Request.UrlReferrer != null)
returnUrl = Request.UrlReferrer.AbsoluteUri;
ViewData["returnUrl"]=returnUrl;
ViewData ["returnUrl"] = returnUrl;
ViewData ["UserName"] = user;
ViewData ["Title"] = title;
BlogManager.CheckAuthCanEdit (user, title);
if (!confirm)
return View ("RemovePost");
BlogManager.RemovePost (user,title);
return View ("RemoveTitle");
BlogManager.RemoveTitle (user, title);
if (returnUrl == null)
RedirectToAction ("Index",new { user = user });
RedirectToAction ("Index", new { user = user });
return Redirect (returnUrl);
}
private ActionResult Return (string returnUrl)
/// <summary>
/// Removes the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="id">Identifier.</param>
/// <param name="returnUrl">Return URL.</param>
/// <param name="confirm">If set to <c>true</c> confirm.</param>
[Authorize]
public ActionResult RemovePost (long id, string returnUrl, bool confirm = false)
{
if (!string.IsNullOrEmpty (returnUrl))
return Redirect (returnUrl);
else
BlogEntry e = BlogManager.GetForEditing (id);
if (e == null)
return new HttpNotFoundResult ("post id "+id.ToString());
ViewData ["id"] = id;
ViewData ["returnUrl"] = string.IsNullOrWhiteSpace(returnUrl)?
Request.UrlReferrer.AbsoluteUri.ToString(): returnUrl;
// TODO: cleaner way to disallow deletion
if (!confirm)
return View ("RemovePost",e);
BlogManager.RemovePost (id);
if (string.IsNullOrWhiteSpace(returnUrl))
return RedirectToAction ("Index");
return Redirect (returnUrl);
}
}
}

View File

@ -13,6 +13,7 @@ using System.Threading;
using Yavsc.Model.FrontOffice;
using Yavsc.Model.FileSystem;
using Yavsc.Model.Calendar;
using System.Configuration;
namespace Yavsc.Controllers
{
@ -59,7 +60,11 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Estimates (string client)
{
string username = Membership.GetUser ().UserName;
var u = Membership.GetUser ();
if (u == null) // There was no redirection to any login page
throw new ConfigurationErrorsException ("no redirection to any login page");
string username = u.UserName;
Estimate [] estims = wfmgr.GetUserEstimates (username);
ViewData ["UserName"] = username;
ViewData ["ResponsibleCount"] =
@ -73,6 +78,21 @@ namespace Yavsc.Controllers
return View (estims);
}
/// <summary>
/// Estimate the specified id.
/// </summary>
/// <param name="id">Identifier.</param>
public ActionResult Get (long id)
{
Estimate f = wfmgr.GetEstimate (id);
if (f == null) {
ModelState.AddModelError ("Id", "Wrong Id");
return View (new Estimate () { Id=id } );
}
return View (f);
}
/// <summary>
/// Estimate the specified model and submit.
/// </summary>

View File

@ -150,9 +150,11 @@ namespace Yavsc.Controllers
if (mbrs.Count == 1) {
// TODO check the google id
// just set this user as logged on
FormsAuthentication.SetAuthCookie (me.displayName, true);
foreach (MembershipUser u in mbrs) {
string username = u.UserName;
FormsAuthentication.SetAuthCookie (username, true);
}
Session ["returnUrl"] = null;
return Redirect (returnUrl);
}
// else create the account

View File

@ -27,6 +27,8 @@ using System.IO;
using System.Net.Http;
using System.Web.Mvc;
using System.Net;
using MarkdownDeep;
using Yavsc.Helpers;
namespace Yavsc.Formatters
{
@ -84,7 +86,7 @@ namespace Yavsc.Formatters
"href=\"/Theme/style.css\" />" +
"<link rel=\"icon\" type=\"image/png\"" +
" href=\"/favicon.png\" />";
p.InnerHtml = MvcHtmlString.Create (message).ToHtmlString();
p.InnerHtml = MarkdownHelper.Markdown(message).ToHtmlString();
h1.InnerHtml = MvcHtmlString.Create (Title).ToHtmlString();
body.InnerHtml = h1.ToString()+p.ToString ();
doc.InnerHtml = head.ToString()+"\n"+body.ToString ();

View File

@ -50,5 +50,8 @@ namespace Yavsc.Formatters
public FormatterException(string message,Exception innerException):base(message,innerException)
{
}
public string Output { get; set; }
public string Error { get; set; }
}
}

View File

@ -77,38 +77,46 @@ namespace Yavsc.Formatters
/// <param name="contentHeaders">Content headers.</param>
public override void WriteToStream (Type type, object value, Stream stream, HttpContentHeaders contentHeaders)
{
string temp = Path.GetTempPath ();
string cntStr = value as string;
string name = "tmpdoc-"+Guid.NewGuid().ToString();
string fullname = Path.Combine (
HttpRuntime.CodegenDir, name);
string fullname = Path.Combine (temp, name);
FileInfo fi = new FileInfo(fullname + ".tex");
FileInfo fo = new FileInfo(fullname + ".pdf");
using (StreamWriter sw = new StreamWriter (fi.FullName))
FileInfo fo = null;
using (StreamWriter sw = new StreamWriter (fi.OpenWrite()))
{
sw.Write (cntStr);
}
using (Process p = new Process ()) {
p.StartInfo.WorkingDirectory = HttpRuntime.CodegenDir;
p.StartInfo = new ProcessStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "/usr/bin/texi2pdf";
p.StartInfo.Arguments =
string.Format ("--batch --build-dir={2} -o {0} {1}",
fo.FullName,
fi.FullName,HttpRuntime.CodegenDir);
p.Start ();
p.WaitForExit ();
if (p.ExitCode != 0)
throw new FormatterException ("Pdf generation failed with exit code:" + p.ExitCode);
sw.Close ();
}
using (StreamReader sr = new StreamReader (fo.FullName)) {
byte[] buffer = File.ReadAllBytes (fo.FullName);
stream.Write(buffer,0,buffer.Length);
using (Process p = new Process ()) {
Directory.SetCurrentDirectory (temp);
p.StartInfo.WorkingDirectory = temp;
p.StartInfo = new ProcessStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "texi2pdf";
p.StartInfo.Arguments =
string.Format ("--batch {0}",
fi.FullName);
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start ();
p.WaitForExit ();
if (p.ExitCode != 0) {
var ex = new FormatterException ("Pdf generation failed with exit code:" + p.ExitCode);
ex.Output = p.StandardOutput.ReadToEnd ()+"\nCWD:"+temp;
ex.Error = p.StandardError.ReadToEnd ();
throw ex;
}
fo = new FileInfo(name + ".pdf");
}
fi.Delete();
fo.Delete();
byte[] buffer = File.ReadAllBytes (fo.Name);
stream.Write(buffer,0,buffer.Length);
if (contentHeaders != null)
SetFileName(contentHeaders, value.GetHashCode ().ToString ());
}

View File

@ -45,28 +45,28 @@ namespace Yavsc
routes.IgnoreRoute ("favicon.ico");
routes.IgnoreRoute ("favicon.png");
routes.IgnoreRoute ("robots.txt");
routes.MapRoute (
"Blog",
"Blog/{user}/{title}",
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
routes.MapRoute (
"Blogs",
"Blogs/{action}/{user}/{title}",
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
/*routes.MapRoute (
"Account",
"Account/{action}/{user}",
new { controller = "Account", action = "Index", user=UrlParameter.Optional }
); */
routes.MapRoute (
"BlogByTitleRO",
"Blog/{user}/{title}",
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
routes.MapRoute (
"BlogById",
"B/{action}/{id}",
new { controller = "Blogs", action = "UserPost", id = UrlParameter.Optional }
);
routes.MapRoute (
"Default",
"{controller}/{action}/{user}/{title}",
"{controller}/{action}/{id}",
new { controller = defaultController,
action = "Index",
user=UrlParameter.Optional,
title = UrlParameter.Optional }
id = UrlParameter.Optional }
);
}

View File

@ -1,4 +1,4 @@
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<asp:ContentPlaceHolder id="init" runat="server">
@ -9,9 +9,9 @@ ViewState["orgtitle"] = T.GetString(Page.Title);
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/Theme/style.css" />
<link rel="stylesheet" href="~/App_Themes/style.css" />
<link rel="icon" type="image/png" href="/favicon.png?v=3" />
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-2.1.4.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-2.1.4.min.js")%>"></script>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<link href='http://fonts.googleapis.com/css?family=Dancing+Script:400,700' rel='stylesheet' type='text/css'/>
@ -19,9 +19,10 @@ ViewState["orgtitle"] = T.GetString(Page.Title);
<body>
<header>
<asp:ContentPlaceHolder ID="overHeaderOne" runat="server">
<h1><a href="<%= Html.Encode(Request.Url.AbsoluteUri.ToString()) %>"> <%=ViewState["orgtitle"]%> </a> -
<h1><a href="<%= Html.Encode(Request.Url.AbsoluteUri.ToString()) %>"> <%=ViewState["orgtitle"]%> </a>
<span> -
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority%>"><%= YavscHelpers.SiteName %></a>
</h1>
</span></h1>
</asp:ContentPlaceHolder><asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder><%
if (ViewData["Error"]!=null) {
%><div class="error"><%= Html.Encode(ViewData["Error"]) %>
@ -36,28 +37,21 @@ ViewState["orgtitle"] = T.GetString(Page.Title);
</main>
<asp:ContentPlaceHolder ID="MASContent" runat="server">
</asp:ContentPlaceHolder>
<aside>
<div id="login" >
<div id="login" ><span class="ohinside">
<a href="<%= Url.Content("~/Blog/"+HttpContext.Current.User.Identity.Name)%>"><img src="/favicon.png" width="25%"/> Votre Blog</a><br/>
<a href="<%= Url.Content("~/")%>">
<span class="c2"><%=Html.Encode(YavscHelpers.SiteName) %></span></a><br/>
<span class="onhover">Page d'accueil<br/></span></span>
<% if (Membership.GetUser()==null) { %>
<%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ,null, new { @class="actionlink" } ) %>
<span class="hidcom"> Page d'accueil </span>
<%= Html.ActionLink("Login", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery }, new { @class="actionlink" } ) %>
<span class="hidcom">Pour pouvoir poster ou commenter</span>
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/Login"%>?returnUrl=<%=ViewData["returnUrl"]==null?Request.Url.PathAndQuery:(string)ViewData["returnUrl"]%>" class="actionlink">
<img src="/images/sign-in-with-google-s.png" style="max-height:1.5em; max-width:6em;" alt="Google sign in">
</a>
<span class="hidcom">S'authentifier avec son compte Google+</span>
<% } else { %>
<%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "Profile", "Account", new { user= HttpContext.Current.User.Identity.Name}, new { @class="actionlink" }) %>
<span class="hidcom"> &Eacute;dition de votre profile </span>
@ <%= Html.ActionLink( YavscHelpers.SiteName, "Index", "Home" ,null, new { @class="actionlink" }) %>
<span class="hidcom"> Page d'accueil </span>
<a href="/Blogs/Post" class="actionlink">Poster</a>
<span class="hidcom"> &Eacute;dition d'un nouveau billet </span>
<%= Html.ActionLink( "Deconnexion", "Logout", "Account", new { returnUrl=Request.Url.PathAndQuery }, new { @class="actionlink" }) %>
<% } %>
</div>
</aside>
<div class="ohinside"><%= Html.ActionLink("Authentification", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery },null) %>
<span class="onhover">Pourquoi s'authentifier?</span></div><br/>
<% } else { %><span class="ohinside">
<%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "Profile", "Account", new { id = HttpContext.Current.User.Identity.Name }, null) %>
<span class="onhover"> &Eacute;dition de votre profile </span></span><br/>
<a href="/Blogs/Post" class="ohafter">Poster</a>
<span class="onhover"> &Eacute;dition d'un nouveau billet </span><br/>
<%= Html.ActionLink( "Deconnexion", "Logout", "Account", new { returnUrl=Request.Url.PathAndQuery }, null) %>
<% } %></div>
<footer>
<script src="https://apis.google.com/js/platform.js" async defer>
{lang: 'fr'}
@ -71,7 +65,8 @@ ViewState["orgtitle"] = T.GetString(Page.Title);
</footer>
<script type="text/javascript">
var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
</script> <script>
</script>
<script>
$( ".bshd" ).on("click",function(e) {
if (e.target == "[object HTMLElement]") {
var panel = $(this).children(".bshpanel");
@ -83,4 +78,3 @@ $( ".bshd" ).on("click",function(e) {
</script>
</body>
</html>

View File

@ -9,9 +9,9 @@ ViewState["orgtitle"] = T.GetString(Page.Title);
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/Theme/style.css" />
<link rel="stylesheet" href="/App_Themes/style.css" />
<link rel="icon" type="image/png" href="/favicon.png?v=3" />
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-2.1.4.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-2.1.4.min.js")%>"></script>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<link href='http://fonts.googleapis.com/css?family=Dancing+Script:400,700' rel='stylesheet' type='text/css'/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 B

View File

@ -1,39 +0,0 @@
/* tables */
table.tablesorter {
font-family:arial;
background-color: #CDCDCD;
margin:10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
background-color: #e6EEEE;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
}
table.tablesorter thead tr .header {
background-image: url(bg.gif);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter tbody td {
color: #3D3D3D;
padding: 4px;
background-color: #FFF;
vertical-align: top;
}
table.tablesorter tbody tr.odd td {
background-color:#F0F0F6;
}
table.tablesorter thead tr .headerSortUp {
background-image: url(/Theme/blue/asc.gif);
}
table.tablesorter thead tr .headerSortDown {
background-image: url(/Theme/blue/desc.gif);
}
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
background-color: #8dbdd8;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,39 +0,0 @@
table.tablesorter {
font-size: 12px;
background-color: #4D4D4D;
width: 1024px;
border: 1px solid #000;
}
table.tablesorter th {
text-align: left;
padding: 5px;
background-color: #6E6E6E;
}
table.tablesorter td {
color: #FFF;
padding: 5px;
}
table.tablesorter .even {
background-color: #3D3D3D;
}
table.tablesorter .odd {
background-color: #6E6E6E;
}
table.tablesorter .header {
background-image: url(bg.png);
background-repeat: no-repeat;
border-left: 1px solid #FFF;
border-right: 1px solid #000;
border-top: 1px solid #FFF;
padding-left: 30px;
padding-top: 8px;
height: auto;
}
table.tablesorter .headerSortUp {
background-image: url(/Theme/green/asc.png);
background-repeat: no-repeat;
}
table.tablesorter .headerSortDown {
background-image: url(/Theme/green/desc.png);
background-repeat: no-repeat;
}

1225
web/Theme/jquery-ui.css vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,72 +0,0 @@
.ui-timepicker-wrapper {
overflow-y: auto;
height: 150px;
width: 6.5em;
background: #fff;
border: 1px solid #ddd;
-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
box-shadow:0 5px 10px rgba(0,0,0,0.2);
outline: none;
z-index: 10001;
margin: 0;
}
.ui-timepicker-wrapper.ui-timepicker-with-duration {
width: 13em;
}
.ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-30,
.ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-60 {
width: 11em;
}
.ui-timepicker-list {
margin: 0;
padding: 0;
list-style: none;
}
.ui-timepicker-duration {
margin-left: 5px; color: #888;
}
.ui-timepicker-list:hover .ui-timepicker-duration {
color: #888;
}
.ui-timepicker-list li {
padding: 3px 0 3px 5px;
cursor: pointer;
white-space: nowrap;
color: #000;
list-style: none;
margin: 0;
}
.ui-timepicker-list:hover .ui-timepicker-selected {
background: #fff; color: #000;
}
li.ui-timepicker-selected,
.ui-timepicker-list li:hover,
.ui-timepicker-list .ui-timepicker-selected:hover {
background: #1980EC; color: #fff;
}
li.ui-timepicker-selected .ui-timepicker-duration,
.ui-timepicker-list li:hover .ui-timepicker-duration {
color: #ccc;
}
.ui-timepicker-list li.ui-timepicker-disabled,
.ui-timepicker-list li.ui-timepicker-disabled:hover,
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
color: #888;
cursor: default;
}
.ui-timepicker-list li.ui-timepicker-disabled:hover,
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
background: #f2f2f2;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -1,198 +0,0 @@
div.mdd_modal
{
position:fixed;
top:0;
left:0;
padding:0;
margin:0;
width:100%;
height:100%;
z-index:1000;
display:none;
font-size:10pt;
background-image:url(/Theme/md/mdd_modal_background.png);
}
div.mdd_modal_frame
{
width:650px;
height:400px;
z-index:2000;
margin:0 auto;
margin-top:60px;
border:solid 5px #808080;
position:relative;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
div.mdd_modal_button
{
position:absolute;
top:-33px;
right:-5px;
padding-left:10px;
padding-right:10px;
padding-top:4px;
padding-bottom:0px;
height:20px;
z-index:1999;
border-radius:4px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
line-height:1em;
}
div.mdd_modal_button a
{
text-decoration:none;
}
div.mdd_modal_button a:hover
{
}
div.mdd_modal_content
{
overflow:scroll;
overflow-x:hidden;
position:relative;
width:100%;
height:100%;
}
div.mdd_ajax_loader
{
background-position: center center;
background-image: url(/Theme/md/mdd_ajax_loader.gif);
background-repeat: no-repeat;
width:100%;
height:200px;
}
div.mdd_syntax
{
font-size:12pt;
padding:10px;
}
div.mdd_syntax h2
{
font-size:14pt;
}
div.mdd_syntax h3
{
font-size:12pt;
}
div.mdd_syntax pre
{
font-size:10pt;
border:solid 1px silver;
padding:4px;
color: black;
background-color:#f8f8f8;
}
div.mdd_toolbar
{
float:left;
padding:5px;
width:100%;
height:20px;
}
div.mdd_toolbar ul
{
margin:0;
padding:0;
}
div.mdd_toolbar li
{
float:left;
margin:0;
padding:0;
list-style:none;
background-color:#777;
color:black;
}
div.mdd_toolbar a.mdd_button
{
background-image:url(/Theme/md/mdd_toolbar.png);
width:20px;
height:20px;
display:block;
}
span.mdd_sep
{
width:5px;
height:20px;
display:block;
border-left:solid 1px #808080;
margin-left:5px;
}
#mdd_bold { background-position:-1px -1px;}
#mdd_bold:hover { background-position:-1px -23px; }
#mdd_italic { background-position:-23px -1px; }
#mdd_italic:hover { background-position:-23px -23px; }
#mdd_ullist { background-position:-177px -1px; }
#mdd_ullist:hover { background-position:-177px -23px; }
#mdd_ollist { background-position:-155px -1px; }
#mdd_ollist:hover { background-position:-155px -23px; }
#mdd_indent { background-position:-67px -1px; }
#mdd_indent:hover { background-position:-67px -23px; }
#mdd_outdent { background-position:-89px -1px; }
#mdd_outdent:hover { background-position:-89px -23px; }
#mdd_link { background-position:-45px -1px; }
#mdd_link:hover { background-position:-45px -23px; }
#mdd_img { background-position:-133px -1px; }
#mdd_img:hover { background-position:-133px -23px; }
#mdd_hr { background-position:-221px -1px; }
#mdd_hr:hover { background-position:-221px -23px; }
#mdd_code { background-position:-111px -1px; }
#mdd_code:hover { background-position:-111px -23px; }
#mdd_heading { background-position:-199px -1px; }
#mdd_heading:hover { background-position:-199px -23px; }
#mdd_undo { background-position:-243px -1px; }
#mdd_undo:hover { background-position:-243px -23px; }
#mdd_redo { background-position:-265px -1px; }
#mdd_redo:hover { background-position:-265px -23px; }
div.mdd_links
{
float:right;
}
div.mdd_links a
{
text-decoration:none;
font-size:smaller;
}
div.mdd_links a:hover
{
}
textarea.mdd_editor
{
width:100%;
margin:0;
}
div.mdd_resizer
{
background:#f8f8f8;
background-image:url("/Theme/md/mdd_gripper.png");
background-position:center center;
background-repeat:no-repeat;
width:100%;
padding-left:2px;
padding-right:2px;
height:9px;
border:solid 1px #d0d0d0;
margin-top:-1px;
cursor:n-resize;
}

View File

@ -1,256 +0,0 @@
body {
background: black;
background-image: url('/images/Banner.png');
background-repeat: no-repeat;
color: #D0FFD0;
font-family: 'Arial', cursive;
padding: .5em;
margin-bottom:2.8em;
}
textarea {
width:25em;
height:5em;
}
input, textarea, checkbox {
color: #FFFFA0;
background: black;
}
main {
background-color: rgba(17,0,23,0.65);
float:left;
}
fieldset {
background-color: rgba(32,16,16,0.8);
border-radius:5px; border: solid 1px #000060;
float:left;
}
video,img {
max-width:100%;
max-height:75%;
position:relative;
}
footer {
position:fixed;
bottom:0;
left:0;
right:0;
background-color:rgba(16,0,0,0.8);
display: flex;
z-index:-1;
font-size: smaller;
}
.thanks {
max-width: 10%;
text-align: center;
vertical-align: text-bottom;
font-size:smaller;
display:block;
bottom:0;
}
#logo {
float: left;
}
.panel,.bshpanel,aside {
background-color: rgba(32,16,16,0.8);
border-radius:5px; border: solid 1px #000060;
float: right;
margin:.5em;
padding: .5em;
}
.bsh { float: right; }
#login {
top:0;
right:0;
background-color:rgba(16,16,0,0.8);
justify-content: space-around;
text-align: center;
}
header {
background-color:rgba(16,16,0,0.8);
top:0;
left:0;
right:0;
text-align: center;
}
h1 img { vertical-align: text-top; }
a {
text-decoration: none;
color: #B0B080;
background-color:rgba(20,0,20,0.5);
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #90B090;
}
label {
font-size: medium;
}
.message {
font-size: large;
background-color: rgba(0,64,0,0.1);
}
.error {
color: #f88;
font-size: large;
background-color: rgba(128,0,0,0.3);
}
.validation-summary-errors{
color: #f88;
background-color: rgba(64,0,0,0.3);
}
.editblog {
width: 95%;
height: 95%;
}
.metablog {
font-style: italic;
font-size: small;
text-align: right;
display: inline;
}
.blogtitle {
display:inline;
}
.contenu {
padding-left: 20px;
}
.validation-summary-errors{
color: #f88;
}
.actionlink {
color: #B0B080;
border: solid 1px rgb(128,128,128);
border-radius:5px;
background-color:rgba(0,0,32,0.8);
font-size:large;
cursor: pointer;
font-family: 'Arial', cursive;
}
input, select {
color: #B0B080;
border: solid 1px rgb(128,128,128);
border-radius:5px;
background-color:rgba(0,0,32,0.8);
font-family: 'Arial', cursive;
}
a.actionlink img { top:4px; }
.actionlink:hover {
background-color:rgba(30,0,124,0.9);
border : solid 1px white;
text-decoration: underline;
}
.code {
font-family: "monospace";
background-color: rgba(0,0,256,0.1);
border-radius:25px;
white-space: pre-wrap;
}
.avatar {
max-width: 64px;
max-height: 64px;
}
.hidden {
display:none;
}
.shoh { display:inline; }
.hiduh {
display:none;
}
.shoh:hover {
background-color: rgba(0,60,40,.3);
border: solid rgb(256,256,0);
}
.shoh:hover + .hiduh {
display:block; position:absolute; left:20px; right:20px;
background-color: rgb(0,0,40); border: solid rgb(256,256,0);
}
.comment {
border-radius:25px;
border-width:1px;
border-style: solid;
border-color:rgb(0,64,0);
font-size: smaller;
}
.hidcom {
display:none; position:fixed; z-index:2;
padding:5px; margin:5px;
background-color: rgba(0,0,40,.8);
}
a.actionlink:hover + .hidcom {
display:block;
}
.input-validation-error { border: solid 1px red; }
.field-validation-error { color: red; }
@media print {
body {background-color:white;color:black;}
header,footer,.postcomment,.actionlink,.metablog,#login{ display:none;}
}
@media all and (min-width: 641px) {
.bshpanel { display:block; }
.bsh { display: none; }
}
@media all and (max-width: 640px) {
.bshpanel { cursor:zoom-in; }
.bshd:hover > .bshpanel {
display: block;
}
.bshd:hover > .bsh {
display: none;
}
footer {
font-size: x-small;
}
body { font-size: smaller; }
}
@media all and (max-width: 350px) {
footer { font-size: xx-small; }
}
}

View File

@ -13,7 +13,7 @@
</thead>
<tbody id="tbcb">
<% int lc=0;
foreach (SelectListItem ci in Model) { lc++; %>
foreach (SelectListItem ci in (IEnumerable<SelectListItem>) ViewData["Circles"]) { lc++; %>
<tr class="<%= (lc%2==0)?"even ":"odd " %>row" id="c_<%=ci.Value%>">
<td><%=ci.Text%></td>
<td>

View File

@ -1,5 +1,6 @@
<%@ Page Title="Login" Language="C#" Inherits="System.Web.Mvc.ViewPage<LoginModel>" MasterPageFile="~/Models/NoLogin.master" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<div class="panel">
<%= Html.ValidationSummary("Ouverture de session") %>
<% using(Html.BeginForm("Login", "Account")) %>
<% { %>
@ -17,13 +18,14 @@
<%= Html.Hidden("returnUrl",ViewData["returnUrl"]) %>
<!-- Html.AntiForgeryToken() -->
<input type="submit"/>
<% } %>
<% } %></div>
<div class="panel">
<%= Html.ActionLink("S'enregistrer","Register",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %>
</div>
<div class="panel">
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/Login"%>?returnUrl=<%=ViewData["returnUrl"]==null?Request.Url.PathAndQuery:(string)ViewData["returnUrl"]%>" class="actionlink">
Identification avec un compte Google
<img src="/images/sign-in-with-google.png" style="max-height:1.5em; max-width:6em;" alt="Google sign in">
</a>
</div>
</asp:Content>

View File

@ -1,4 +1,4 @@
<%@ Page Title="Register" Language="C#" Inherits="System.Web.Mvc.ViewPages<RegisterViewModel>" MasterPageFile="~/Models/App.master" %>
<%@ Page Title="Register" Language="C#" Inherits="System.Web.Mvc.ViewPage<RegisterViewModel>" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<%= Html.ValidationSummary() %>

View File

@ -1,14 +1,14 @@
<%@ Page Title="Bill edition" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntry>" MasterPageFile="~/Models/App.master" %>
<%@ Page Title="Bill_edition" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntry>" MasterPageFile="~/Models/App.master" %>
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
<asp:Content ContentPlaceHolderID="head" ID="HeadContent1" runat="server">
<link rel="stylesheet" href="<%=Url.Content("~/Theme/mdd_styles.css")%>">
<link rel="stylesheet" href="<%=Url.Content("~/Scripts/mdd_styles.css")%>">
<script type="text/javascript" src="<%=Url.Content("~/Scripts/MarkdownDeepLib.min.js")%>">
</script>
</script>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% if (Model != null ) if (Model.Content != null ) { %>
<%= Html.ActionLink(Model.Title,"UserPost",new{user=Model.UserName,title=Model.Title}) %>
<%= Html.ActionLink(Model.Title,"UserPost",new{user=Model.UserName,title=Model.Title,id=Model.Id}) %>
<% } %>
@ -28,8 +28,6 @@
<%= Html.CheckBox( "Visible" ) %>
<%= Html.LabelFor(model => model.Visible) %>
<%= Html.ValidationMessage("Visible", "*") %>
<br/>
@ -46,7 +44,6 @@
<% } %>
<script>
$(document).ready(function () {
$("textarea.mdd_editor").MarkdownDeep({
help_location: "/Scripts/html/mdd_help.htm",

View File

@ -1,26 +1,36 @@
<%@ Page Title="Blogs - Les dernières parutions" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntryCollection>" MasterPageFile="~/Models/App.master"%>
<%@ Page Title="Blogs - Indexe" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntryCollection>" MasterPageFile="~/Models/App.master" EnableTheming="True" StylesheetTheme="dark" %>
<%@ Register Assembly="Yavsc.WebControls" TagPrefix="yavsc" Namespace="Yavsc.WebControls" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% foreach (BlogEntry e in this.Model) { %>
<div class="blogpost">
<h3 class="blogtitle">
<%= Html.ActionLink(e.Title,"UserPost", new { user=e.UserName, title = e.Title }) %>
</h3>
<div class="metablog">(<%=Html.Encode(e.UserName)%> <%=e.Modified.ToString("yyyy/MM/dd") %>)
<% if (Membership.GetUser()!=null)
if (Membership.GetUser().UserName==e.UserName)
{ %>
<%= Html.ActionLink("Editer","Edit", new { user = e.UserName, title = e.Title }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { user = e.UserName, title = e.Title }, new { @class="actionlink" } ) %>
<% } %>
</div>
<div>
<table>
<% foreach (var g in Model.GroupByUser()) { %>
<tr><th><%= Html.ActionLink(g.Key, "Index",
new { user = g.Key }, new { @class = "userref" } ) %>
</th></tr>
<% foreach (var p in g) { %>
<tr>
<td>
<%= Html.ActionLink(p.Title, "UserPost",
new { user = g.Key, title = p.Title }, new { @class = "usertitleref" } ) %>
le <%=p.Posted.ToString("D") %>
</td>
<% if (Membership.GetUser()!=null)
if ((Membership.GetUser().UserName==g.Key)
|| (Roles.IsUserInRole ("Admin")))
{ %><td>
<%= Html.ActionLink("Editer","Edit", new { id = p.Id }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { id = p.Id }, new { @class="actionlink" } ) %>
</td><% } %>
</tr> <% } %>
<% } %>
</table>
</div>
<% } %>
<form runat="server" id="form1" method="GET">
<% rp1.ResultCount = (int) ViewData["RecordCount"];
rp1.CurrentPage = (int) ViewData["PageIndex"]; %>
<% rp1.ResultCount = Model.Count; rp1.ResultsPerPage = 50; %>
<% rp1.CurrentPage = (int) ViewData["PageIndex"]; %>
<yavsc:ResultPages id="rp1" Action = "?pageIndex={0}" runat="server" ></yavsc:ResultPages>
</form>

View File

@ -3,21 +3,18 @@
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<%= Html.ValidationSummary() %>
<% using (Html.BeginForm("RemovePost","Blogs")) { %>
<% using (Html.BeginForm("RemovePost","Blogs",new {id=Model.Id})) { %>
<%= Html.LabelFor(model => model.Title) %> :
<%= Html.TextBox( "Title" ) %>
<%= Html.ValidationMessage("Title", "*") %><br/>
Identifiant du post : <%= ViewData["pid"] %><br/>
Identifiant du post : <%= Model.Id %><br/>
<span class="preview"><%= Html.Markdown(Model.Content) %></span>
<label for="confirm">supprimer le billet</label>
<%= Html.CheckBox( "confirm" ) %>
<%= Html.ValidationMessage("AgreeToRemove", "*") %>
<%= Html.Hidden("pid") %>
<%= Html.ValidationMessage("confirm", "*") %>
<%= Html.Hidden("returnUrl") %>
<input type="submit"/>
<% } %>
</asp:Content>

View File

@ -5,9 +5,9 @@
<%= Html.ValidationSummary() %>
<% using (Html.BeginForm("RemoveTitle","Blogs")) { %>
<%= Html.LabelFor(model => model.Title) %> :
<%= Html.TextBox( "Title" ) %>
<%= Html.ValidationMessage("Title", "*") %><br/>
<%= Html.LabelFor(model => model.Titles) %> :
<%= Html.TextBox( "Titles" ) %>
<%= Html.ValidationMessage("Titles", "*") %><br/>
<%= Html.Hidden("UserName") %>
<label for="confirm">supprimer le billet</label>
<%= Html.CheckBox( "confirm" ) %>

View File

@ -1,60 +1,48 @@
<%@ Page Title="Billet" Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEntry>" MasterPageFile="~/Models/App.master"%>
<%@ Page Title="Billet" Language="C#" Inherits="System.Web.Mvc.ViewPage<UUTBlogEntryCollection>" MasterPageFile="~/Models/App.master"%>
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
<% Title = Model.Title+" - "+((string) ((Profile)ViewData["BlogUserProfile"]).BlogTitle) ; %>
<% Title = Model.Title+ " - " + ViewData ["BlogTitle"] ; %>
</asp:Content>
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="header1" runat="server">
<h1 class="blogtitle">
<%= Html.ActionLink(Model.Title,"UserPost",new{user=Model.UserName,title=Model.Title}) %> -
<a href="/Blog/<%=Model.UserName%>">
<% if (ViewData["Avatar"]!=null) { %>
<img class="avatar" src="<%=ViewData["Avatar"]%>" alt="" id="logo"/>
<% } %>
<%=Html.Encode(ViewData["BlogTitle"])%>
</a> -
<h1 class="blogtitle"><% if (ViewData["Avatar"]!=null) { %>
<img src="<%=ViewData["Avatar"]%>" alt="" id="logo"/>
<% } %>
<%= Html.ActionLink(Model.Title,"UserPost","Blog",new{user=Model.UserName, title = Model.Title}) %>
<span class="c2"> - <%= Html.ActionLink((string)ViewData ["BlogTitle"] ,"UserPosts",new{user=Model.UserName}) %>
</span>
<span class="c3"> -
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority%>"><%= YavscHelpers.SiteName %></a>
</span>
</h1>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% foreach (var be in Model) { %>
<div class="blogpost">
<%= Html.Markdown(Model.Content) %>
<%= Html.Markdown(be.Content) %>
</div>
<%
string username = "";
if (Membership.GetUser()!=null)
username = Membership.GetUser().UserName; %>
<% foreach (var c in (Comment[])ViewData["Comments"]) { %>
<% if (Membership.GetUser()!=null) {
if (Membership.GetUser().UserName==be.UserName)
{ %> <div class="metapost">
<%= Html.ActionLink("Editer","Edit", new { id = be.Id }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { id = be.Id }, new { @class="actionlink" } ) %>
</div> <% } %>
<%
string username = Membership.GetUser().UserName; %>
<% foreach (var c in (Comment[]) BlogManager.GetComments(be.Id)) { %>
<div class="comment" style="min-height:32px;"> <img style="clear:left;float:left;max-width:32px;max-height:32px;margin:.3em;" src="/Blogs/Avatar/<%=c.From%>" alt="<%=c.From%>"/>
<%= Html.Markdown(c.CommentText) %>
<% if ( username == Model.UserName || c.From == username ) { %>
<%= Html.ActionLink("Supprimer","RemoveComment", new { cmtid = c.Id } , new { @class="actionlink" })%>
<% } %>
</div>
<% } %>
</asp:Content>
<asp:Content ContentPlaceHolderID="MASContent" ID="mas1" runat="server">
<% if (Membership.GetUser()!=null) {
%>
<div class="postcomment">
</div><% } %>
<div class="postcomment">
<% using (Html.BeginForm("Comment","Blogs")) { %>
<%=Html.Hidden("UserName")%>
<%=Html.Hidden("Title")%>
<%=Html.TextArea("CommentText","")%>
<%=Html.Hidden("PostId",Model.Id)%>
<%=Html.Hidden("PostId",be.Id)%>
<input type="submit" value="Poster un commentaire"/>
<% } %>
</div>
<%
if (Membership.GetUser().UserName==Model.UserName)
{ %>
<aside>
<%= Html.ActionLink("Editer","Edit", new { user = Model.UserName, title = Model.Title }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { user = Model.UserName, title = Model.Title }, new { @class="actionlink" } ) %>
<% } } %>
</aside>
</asp:Content>
<% } %><% } %>
</asp:Content>

View File

@ -20,9 +20,15 @@
<% foreach (BlogEntry e in this.Model) { %>
<div <% if (!e.Visible) { %> style="background-color:#022;" <% } %>>
<h2 class="blogtitle" ><%= Html.ActionLink(e.Title,"UserPost", new { user=e.UserName, title = e.Title }) %></h2>
<h2 class="blogtitle" ><%= Html.ActionLink(e.Title,"GetPost", new { id = e.Id }) %></h2>
<div class="metablog">(<%= e.Posted.ToString("yyyy/MM/dd") %>
- <%= e.Modified.ToString("yyyy/MM/dd") %> <%= e.Visible? "":", Invisible!" %>)
<% if (Membership.GetUser()!=null)
if (Membership.GetUser().UserName==e.UserName)
{ %>
<%= Html.ActionLink("Editer","Edit", new { id = e.Id }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { id = e.Id }, new { @class="actionlink" } ) %>
<% } %>
</div>
</div>

View File

@ -7,19 +7,18 @@ Les estimations que vous avez faites (<%=ViewData["ResponsibleCount"]%>):<br>
foreach (Estimate estim in Model) {
if (string.Compare(estim.Responsible,(string) ViewData["UserName"])==0) { %>
<%= Html.ActionLink("Titre:"+estim.Title+" Client:"+estim.Client+" Id:"+estim.Id.ToString(),"Estimate",new {Id=estim.Id}) %>
<%= Html.ActionLink("Titre:"+estim.Title+" Client:"+estim.Client,"Estimate",new{id=estim.Id}) %>
<br>
<% }}%>
</div>
<% } %>
<% if (((int)ViewData["ClientCount"])>0) { %>
<div>
Vos estimations <% if (((int)ViewData["ResponsibleCount"])>0) { %>
en tant que client
<% } %> (<%=ViewData["ClientCount"]%>):<br>
<% foreach (Estimate estim in Model) {
if (string.Compare(estim.Client,(string)ViewData["UserName"])==0) { %>
<%= Html.ActionLink("Titre:"+estim.Title+" Responsable:"+estim.Responsible+" Id:"+estim.Id.ToString(),"Estimate",new {Id=estim.Id}) %>
<br>
<% }} %>
Vos estimations en tant que client
(<%=ViewData["ClientCount"]%>):<br>
<% foreach (Estimate estim in Model) { %>
<%= Html.ActionLink("Titre:"+estim.Title+" Responsable:"+estim.Responsible,"Estimate",new{id=estim.Id}) %>
<br><% } %>
</div>
<% } %>
</asp:Content>

View File

@ -1,4 +1,4 @@
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<Yavsc.ApiControllers.Calendar.Model.EventPub>" %>
<%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage<EventPub>" %>
<asp:Content ID="MainContentContent" ContentPlaceHolderID="MainContent" runat="server">

View File

@ -4,7 +4,6 @@
<% using (Html.BeginForm("Write","WorkFlow")) { %>
<div>
<%= Html.Hidden( "Id" ) %>
<%= Html.Hidden( "EstimateId", (long) ViewData["EstimateId"]) %>
<%= Html.LabelFor(model => model.Description) %>:<%= Html.TextArea( "Description" ) %>
<%= Html.ValidationMessage("Description", "*", new { @id="Err_wr_Description", @class="error" }) %>

View File

@ -27,6 +27,9 @@
<add namespace="Yavsc.Model.Google" />
<add namespace="Yavsc.Model.FrontOffice" />
<add namespace="Yavsc.Model.Circles" />
<add namespace="Yavsc.Model.Calendar" />
<add namespace="System.Collections.Generic" />
</namespaces>
</pages>
</system.web>

View File

@ -26,6 +26,7 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<section name="catalog" type="Yavsc.Model.FrontOffice.Configuration.CatalogProvidersConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
<section name="workflow" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" allowLocation="true" requirePermission="false" allowDefinition="Everywhere" />
<section name="circleProviders" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" />
<section name="userNameManager" type="Yavsc.Model.DataProviderConfigurationSection, YavscModel" />
</sectionGroup>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
@ -84,7 +85,7 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
<httpRuntime maxRequestLength="52428800" />
<trace enabled="true" localOnly="true" pageOutput="true" requestLimit="10" traceMode="SortByTime" />
<trace enabled="false" localOnly="true" pageOutput="true" requestLimit="10" traceMode="SortByTime" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto" enableClientBasedCulture="true" />
<membership defaultProvider="NpgsqlMembershipProvider" userIsOnlineTimeWindow="1">
<providers>
@ -98,6 +99,11 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add name="NpgsqlRoleProvider" connectionStringName="yavsc" applicationName="/" type="Npgsql.Web.NpgsqlRoleProvider, NpgsqlMRPProviders" autogenerateschema="false" />
</providers>
</roleManager>
<userNameManager defaultProvider="NpsqlUserNameProvider">
<providers>
<add name="NpsqlUserNameProvider" connectionStringName="yavsc" applicationName="/" type="Npgsql.Web.RolesAndMembers.NpgsqlUserNameProvider, NpgsqlMRPProviders" autogenerateschema="false" ></add>
</providers>
</userNameManager>
<workflow defaultProvider="ITProvider">
<providers>
<clear />

View File

@ -125,10 +125,6 @@
<Folder Include="CatExts\" />
<Folder Include="Views\WorkFlow\" />
<Folder Include="Views\Admin\" />
<Folder Include="Theme\" />
<Folder Include="Theme\green\" />
<Folder Include="Theme\blue\" />
<Folder Include="Theme\dark\" />
<Folder Include="templates\" />
<Folder Include="Formatters\" />
<Folder Include="Settings\" />
@ -141,6 +137,10 @@
<Folder Include="ApiControllers\" />
<Folder Include="Views\Modules\" />
<Folder Include="Views\Calendar\" />
<Folder Include="App_Themes\" />
<Folder Include="App_Themes\green\" />
<Folder Include="App_Themes\blue\" />
<Folder Include="App_Themes\dark\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\HomeController.cs" />
@ -208,6 +208,7 @@
<Compile Include="Helpers\Google\OAuth2.cs" />
<Compile Include="Helpers\Google\PeopleApi.cs" />
<Compile Include="ApiControllers\PaypalController.cs" />
<Compile Include="ApiControllers\AuthorizationDenied.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />
@ -260,18 +261,6 @@
<Content Include="Views\Admin\Restore.aspx" />
<Content Include="Views\Admin\Restored.aspx" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Theme\style.css" />
<Content Include="Theme\green\asc.png" />
<Content Include="Theme\green\bg.png" />
<Content Include="Theme\green\desc.png" />
<Content Include="Theme\green\style.css" />
<Content Include="Theme\blue\asc.gif" />
<Content Include="Theme\blue\bg.gif" />
<Content Include="Theme\blue\desc.gif" />
<Content Include="Theme\blue\style.css" />
<Content Include="Theme\dark\asc.gif" />
<Content Include="Theme\dark\bg.gif" />
<Content Include="Theme\dark\desc.gif" />
<Content Include="Views\FrontOffice\Estimates.aspx" />
<Content Include="images\pgsql.png" />
<Content Include="Catalog.xml" />
@ -284,9 +273,6 @@
<Content Include="Scripts\GruntFile.js" />
<Content Include="Scripts\jquery.timepicker.js" />
<Content Include="Scripts\jquery.timepicker.min.js" />
<Content Include="Theme\jquery.timepicker.css" />
<Content Include="Theme\jquery-ui.css" />
<Content Include="Theme\jquery-ui.min.css" />
<Content Include="Scripts\jquery.mousewheel.js" />
<Content Include="Views\Admin\RemoveUser.aspx" />
<Content Include="Views\FrontOffice\Index.aspx" />
@ -301,21 +287,14 @@
<Content Include="favicon.png" />
<Content Include="Models\NoLogin.master" />
<Content Include="Views\FrontOffice\Basket.aspx" />
<Content Include="Theme\dark\rect.png" />
<Content Include="Scripts\stupidtable.js" />
<Content Include="Scripts\jquery-ui.js" />
<Content Include="Views\Account\Profile.aspx" />
<Content Include="robots.txt" />
<Content Include="Scripts\form-new-user.js" />
<Content Include="Views\FrontOffice\Estimate.aspx" />
<Content Include="Theme\dark\croix.png" />
<Content Include="Views\Admin\RemoveRole..aspx" />
<Content Include="Views\FrontOffice\EventPub.aspx" />
<Content Include="Theme\md\mdd_toolbar.png" />
<Content Include="Theme\md\mdd_ajax_loader.gif" />
<Content Include="Theme\md\mdd_gripper.png" />
<Content Include="Theme\md\mdd_modal_background.png" />
<Content Include="Theme\mdd_styles.css" />
<Content Include="Views\Account\Circles.aspx" />
<Content Include="Views\Account\Register.ascx" />
<Content Include="Views\Account\ResetPassword.aspx" />
@ -333,6 +312,30 @@
<Content Include="Views\Calendar\ChooseADate.aspx" />
<Content Include="Views\Calendar\ErrorMessage.aspx" />
<Content Include="Views\Blogs\RemoveTitle.aspx" />
<Content Include="App_Themes\style.css" />
<Content Include="App_Themes\green\asc.png" />
<Content Include="App_Themes\green\bg.png" />
<Content Include="App_Themes\green\desc.png" />
<Content Include="App_Themes\green\style.css" />
<Content Include="App_Themes\blue\asc.gif" />
<Content Include="App_Themes\blue\bg.gif" />
<Content Include="App_Themes\blue\desc.gif" />
<Content Include="App_Themes\blue\style.css" />
<Content Include="App_Themes\dark\asc.gif" />
<Content Include="App_Themes\dark\bg.gif" />
<Content Include="App_Themes\dark\desc.gif" />
<Content Include="App_Themes\jquery.timepicker.css" />
<Content Include="App_Themes\jquery-ui.css" />
<Content Include="App_Themes\jquery-ui.min.css" />
<Content Include="App_Themes\dark\rect.png" />
<Content Include="App_Themes\dark\croix.png" />
<Content Include="App_Themes\md\mdd_toolbar.png" />
<Content Include="App_Themes\md\mdd_ajax_loader.gif" />
<Content Include="App_Themes\md\mdd_gripper.png" />
<Content Include="App_Themes\md\mdd_modal_background.png" />
<Content Include="App_Themes\mdd_styles.css" />
<Content Include="Scripts\jquery-2.1.4.min.js" />
<Content Include="Scripts\MarkdownDeepLib.min.js" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@ -2,6 +2,7 @@ using System;
using System.Configuration;
using System.Collections.Generic;
using Yavsc.Model.Blogs;
using System.Linq;
namespace Yavsc.Model.Blogs
{
@ -10,6 +11,155 @@ namespace Yavsc.Model.Blogs
/// </summary>
public class BlogEntryCollection : List<BlogEntry>
{
public BlogEntryCollection ()
{
}
public BlogEntryCollection(IEnumerable<BlogEntry> items)
{
if (items!=null)
this.AddRange (items);
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/>.</returns>
public override string ToString ()
{
string titles = Titles == null ?
"none" : string.Join (", ", Titles);
return string.Format ("[BlogEntryCollection: Titles={0}]", titles);
}
/// <summary>
/// Get the specified bid.
/// </summary>
/// <param name="bid">Bid.</param>
public BlogEntry Get (long bid)
{
return this.First (x => x.Id == bid);
}
/// <summary>
/// Filters this collection on
/// the given title.
/// </summary>
/// <returns>The by title.</returns>
/// <param name="title">Title.</param>
public BlogEntry [] FilterOnTitle (string title)
{
return this.Where (x => x.Title == title).ToArray ();
}
/// <summary>
/// Post info.
/// </summary>
public struct PostInfoByTitle {
/// <summary>
/// The name of the user.
/// </summary>
public string UserName;
/// <summary>
/// The identifier.
/// </summary>
public long Id;
/// <summary>
/// The posted.
/// </summary>
public DateTime Posted;
/// <summary>
/// The modified.
/// </summary>
public DateTime Modified;
}
public struct PostInfoByUser {
/// <summary>
/// The name of the user.
/// </summary>
public string Title;
/// <summary>
/// The identifier.
/// </summary>
public long Id;
/// <summary>
/// The posted.
/// </summary>
public DateTime Posted;
/// <summary>
/// The modified.
/// </summary>
public DateTime Modified;
}
/// <summary>
/// Groups by title.
/// </summary>
public IEnumerable<IGrouping<string,PostInfoByTitle>> GroupByTitle()
{
return from be in this
orderby be.Posted descending
group
new PostInfoByTitle { UserName=be.UserName, Id=be.Id,
Posted=be.Posted, Modified=be.Modified }
by be.Title
into titlegroup
select titlegroup;
}
/// <summary>
/// Groups by user.
/// </summary>
/// <returns>The by user.</returns>
public IEnumerable<IGrouping<string,PostInfoByUser>> GroupByUser()
{
return from be in this
orderby be.Posted descending
group
new PostInfoByUser { Title=be.Title, Id=be.Id,
Posted=be.Posted, Modified=be.Modified }
by be.UserName
into usergroup
select usergroup;
}
/// <summary>
/// Gets the titles.
/// </summary>
/// <value>The titles.</value>
public string[] Titles { get {
string[] result = this.Select (x => x.Title).Distinct ().ToArray ();
if (result == null)
return new string[0];
return result;
} }
/// <summary>
/// Gets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/> concerns A unique title.
/// </summary>
/// <value><c>true</c> if concerns A unique title; otherwise, <c>false</c>.</value>
public bool ConcernsAUniqueTitle {
get {
if (this.Count <= 1)
return true;
else
return this.All (x => Titles [0] == x.Title);
}
}
/// <summary>
/// Gets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogEntryCollection"/> concerns A unique title.
/// </summary>
/// <value><c>true</c> if concerns A unique title; otherwise, <c>false</c>.</value>
public bool ConcernsAUniqueUser {
get {
if (this.Count <= 1)
return true;
else
return this.All (x => x.UserName == this[0].UserName);
}
}
}
}

View File

@ -5,6 +5,9 @@ using System.Web;
using System.Web.Security;
using Yavsc.Model.Circles;
using System.Web.Mvc;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace Yavsc.Model.Blogs
@ -56,7 +59,7 @@ namespace Yavsc.Model.Blogs
/// <returns>The post.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public static BlogEntry GetPost (string username, string title)
public static UUTBlogEntryCollection GetPost (string username, string title)
{
return Provider.GetPost (username, title);
}
@ -79,7 +82,7 @@ namespace Yavsc.Model.Blogs
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
/// <param name="cids">sets the circles.</param>
public static long Post (string username, string title, string content, bool visible, long [] cids)
public static long Post (string username, string title, string content, bool visible, long[] cids)
{
return Provider.Post (username, title, content, visible, cids);
}
@ -92,9 +95,9 @@ namespace Yavsc.Model.Blogs
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
/// <param name="cids">sets the circles.</param>
public static void UpdatePost (long postid, string title, string content, bool visible,long [] cids)
public static void UpdatePost (long postid, string title, string content, bool visible, long[] cids)
{
Provider.UpdatePost (postid, title, content, visible,cids);
Provider.UpdatePost (postid, title, content, visible, cids);
}
@ -113,23 +116,32 @@ namespace Yavsc.Model.Blogs
return Provider.FindPost (readersName, pattern, searchflags, pageIndex, pageSize, out totalRecords);
}
/// <summary>
/// Removes the post.
/// </summary>
/// <param name="post_id">Post identifier.</param>
public static void RemovePost (long post_id)
{
Provider.RemovePost (post_id);
}
/// <summary>
/// Removes the post.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public static void RemovePost (string username, string title)
public static void RemoveTitle (string username, string title)
{
if (!Roles.IsUserInRole ("Admin")) {
string rguser = Membership.GetUser ().UserName;
if (rguser != username) {
throw new AccessViolationException (
string.Format (
"{1}, Vous n'avez pas le droit de suprimer des billets du Blog de {0}",
"{1}, Vous n'avez pas le droit de suprimer les Blogs de {0}",
username, rguser));
}
}
Provider.RemovePost (username, title);
Provider.RemoveTitle (username, title);
}
/// <summary>
@ -139,9 +151,10 @@ namespace Yavsc.Model.Blogs
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="totalRecords">Total records.</param>
public static BlogEntryCollection LastPosts (int pageIndex, int pageSize, out int totalRecords)
public static IEnumerable<BlogEntry> LastPosts (int pageIndex, int pageSize, out int totalRecords)
{
return Provider.LastPosts (pageIndex, pageSize, out totalRecords);
var c = Provider.LastPosts (pageIndex, pageSize, out totalRecords);
return FilterOnReadAccess (c);
}
/// <summary>
@ -166,6 +179,136 @@ namespace Yavsc.Model.Blogs
return Provider.Tag (postid, tag);
}
/// <summary>
/// Checks the auth can edit.
/// </summary>
/// <returns><c>true</c>, if can edit was authed, <c>false</c> otherwise.</returns>
/// <param name="user">User.</param>
/// <param name="title">Title.</param>
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
public static bool CheckAuthCanEdit (string user, string title, bool throwEx = true)
{
BlogEntryCollection bec = BlogManager.GetPost (user, title);
if (bec == null)
throw new FileNotFoundException ();
if (!Roles.IsUserInRole ("Admin"))
if (bec.Count > 0)
if (Membership.GetUser ().UserName != user) {
if (throwEx)
throw new AccessViolationException (
string.Format (
"Vous n'avez pas le droit d'editer ce blog (title:{0})",
title));
else
return false;
}
return true;
}
/// <summary>
/// Checks the auth can edit.
/// </summary>
/// <returns><c>true</c>, if auth can edit was checked, <c>false</c> otherwise.</returns>
/// <param name="postid">Postid.</param>
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
public static BlogEntry GetForEditing (long postid, bool throwEx = true)
{
BlogEntry e = BlogManager.GetPost (postid);
if (e == null)
throw new PostNotFoundException ();
if (!Roles.IsUserInRole ("Admin")) {
string rguser = Membership.GetUser ().UserName;
if (rguser != e.UserName) {
if (throwEx)
throw new AccessViolationException (
string.Format (
"Vous n'avez pas le droit d'editer ce billet (id:{0})",
e.Id));
else
return null;
}
}
return e;
}
private static bool CanView (BlogEntry e, MembershipUser u = null)
{
if (e.AllowedCircles != null && e.AllowedCircles.Length > 0) {
// only deliver to admins, owner, or specified circle memebers
if (u == null)
return false;
if (u.UserName != e.UserName)
if (!Roles.IsUserInRole (u.UserName, "Admin"))
{
if (!e.Visible)
return false;
if (!CircleManager.DefaultProvider.Matches (e.AllowedCircles, u.UserName))
return false;
}
}
return true;
}
/// <summary>
/// Checks the auth can read.
/// </summary>
/// <returns><c>true</c>, if auth can read was checked, <c>false</c> otherwise.</returns>
/// <param name="postid">Postid.</param>
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
public static BlogEntry GetForReading (long postid, bool throwEx = true)
{
BlogEntry e = BlogManager.GetPost (postid);
if (e == null)
if (throwEx)
throw new FileNotFoundException ();
if ( CanView (e, Membership.GetUser ()))
return e;
if (throwEx)
throw new AccessViolationException (string.Format (
"Vous n'avez pas le droit de lire ce billet (id:{0})",
postid.ToString ()));
return null;
}
/// <summary>
/// Checks the auth can read.
/// </summary>
/// <returns><c>true</c>, if auth can read was checked, <c>false</c> otherwise.</returns>
/// <param name="bec">Bec.</param>
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
private static bool HasReadAccess (BlogEntryCollection bec, bool throwEx = true)
{
if (bec == null)
throw new FileNotFoundException ();
if (Roles.IsUserInRole ("Admin"))
return true;
var u = Membership.GetUser ();
BlogEntry e = bec.First (x=>!CanView(x,u));
if (e == null)
return true;
if (throwEx)
throw new AccessViolationException (
string.Format (
"Vous n'avez pas le droit de lire cette collection de billet (titles:{0})",
bec.ToString()));
else
return false;
}
/// <summary>
/// Filters the on read access.
/// </summary>
/// <returns>The on read access.</returns>
/// <param name="bec">Bec.</param>
/// <typeparam name="TEntry">The 1st type parameter.</typeparam>
public static IEnumerable<TEntry> FilterOnReadAccess<TEntry> ( IEnumerable<TEntry> bec)
{
if (bec == null) return null;
if (Roles.IsUserInRole ("Admin")) return bec;
var u = Membership.GetUser ();
var r = bec.Where (x => CanView (x as BlogEntry, u));
return r;
}
}
}

View File

@ -20,15 +20,17 @@ namespace Yavsc.Model.Blogs
public abstract BlogEntry GetPost (long postid);
/// <summary>
/// Gets the post.
/// Gets the post collection from a given user and at a given title.
/// </summary>
/// <returns>The post.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public abstract BlogEntry GetPost (string username, string title);
public abstract UUTBlogEntryCollection GetPost (string username, string title);
/// <summary>
/// Post the specified username, title, content, visible and allowedCircles.
/// Saves a post from the given username,
/// at the specified title, this content,
/// visible or not, and for allowedCircles.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
@ -39,7 +41,8 @@ namespace Yavsc.Model.Blogs
/// <summary>
/// Updates the post.
/// Updates the post specified by its id,
/// using the given title, content, visibility and circle collection.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="title">Title.</param>
@ -48,9 +51,8 @@ namespace Yavsc.Model.Blogs
/// <param name="allowedCircles">Allowed circles.</param>
public abstract void UpdatePost (long postid, string title, string content, bool visible, long[] allowedCircles);
/// <summary>
/// Finds the post.
/// Finds a post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="readersName">Readers name.</param>
@ -63,11 +65,11 @@ namespace Yavsc.Model.Blogs
int pageIndex, int pageSize, out int totalRecords);
/// <summary>
/// Removes the post.
/// Removes the posts under the specified title and user.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public abstract void RemovePost (string username, string title);
public abstract void RemoveTitle (string username, string title);
/// <summary>
/// Removes the post.
@ -83,7 +85,7 @@ namespace Yavsc.Model.Blogs
public abstract long RemoveComment (long cmtid);
/// <summary>
/// Lasts the posts.
/// Lasts the posts for this application.
/// </summary>
/// <returns>The posts.</returns>
/// <param name="pageIndex">Page index.</param>
@ -92,14 +94,15 @@ namespace Yavsc.Model.Blogs
public abstract BlogEntryCollection LastPosts(int pageIndex, int pageSize, out int totalRecords);
/// <summary>
/// Blogs the title.
/// Returns the user's blog title.
/// </summary>
/// <returns>The title.</returns>
/// <param name="username">Username.</param>
public abstract string BlogTitle (string username);
/// <summary>
/// Comment the specified from, postid and content.
/// Saves a comment from specified user
/// on the specided post using the specified content.
/// </summary>
/// <param name="from">From.</param>
/// <param name="postid">Postid.</param>
@ -107,7 +110,7 @@ namespace Yavsc.Model.Blogs
public abstract long Comment (string from, long postid, string content);
/// <summary>
/// Gets the comments.
/// Gets the comments on a specided post by identifier <c>postid</c>.
/// </summary>
/// <returns>The comments.</returns>
/// <param name="postid">Postid.</param>
@ -115,10 +118,10 @@ namespace Yavsc.Model.Blogs
public abstract Comment[] GetComments (long postid, bool getHidden) ;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogProvider"/> auto validate comment.
/// Gets or sets a value indicating whether this <see cref="Yavsc.Model.Blogs.BlogProvider"/> auto validates comments.
/// </summary>
/// <value><c>true</c> if auto validate comment; otherwise, <c>false</c>.</value>
public abstract bool AutoValidateComment { get; set; }
public abstract bool AutoValidatesComments { get; set; }
/// <summary>
/// Validates the comment.
@ -135,7 +138,8 @@ namespace Yavsc.Model.Blogs
public abstract void UpdateComment (long cmtid, string content, bool visible);
/// <summary>
/// Tag the specified postid and tag.
/// Tag the specified post by identifier
/// using the given tag.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="tag">Tag.</param>

View File

@ -34,12 +34,7 @@ namespace Yavsc.Model.Blogs
/// <param name="username">Username.</param>
/// <param name="items">Items.</param>
public UUBlogEntryCollection(string username,
BlogEntryCollection items = null) {
if (items != null) {
if (!items.ConcernsAUniqueUser)
throw new InvalidOperationException ();
this.AddRange (items);
}
BlogEntryCollection items = null) : base(items) {
_username = username;
}
private string _username;
@ -48,6 +43,11 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <value>The name of the user.</value>
public string UserName { get { return _username; } }
public override string ToString ()
{
return string.Format ("[UUBlogEntryCollection: UserName={0} Count={1}]", UserName, Count);
}
}
}

View File

@ -18,47 +18,46 @@
//
// 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.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web;
using System.Web.Configuration;
using System.Web.Profile;
using System.Web.Security;
using Npgsql.Web.Blog;
using Yavsc;
using Yavsc.Model;
using Yavsc.Model.Blogs;
using Yavsc.ApiControllers;
using Yavsc.Model.RolesAndMembers;
using System.Net;
using System.Web.Mvc;
using Yavsc.Model.Circles;
namespace Yavsc.Controllers
namespace Yavsc.Model.Blogs
{
public class UUTBlogEntryCollection : BlogEntryCollection {
UUTBlogEntryCollection(string username, string title,
public BlogEntryCollection items = null) {
if (items != null) {
if (!items.ConcernsAUniqueTitle && items.ConcernsAUniqueTitle)
/// <summary>
/// Unique User and Title blog entry collection.
/// </summary>
public class UUTBlogEntryCollection : UUBlogEntryCollection {
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/> class.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
/// <param name="items">Items.</param>
public UUTBlogEntryCollection(string username, string title,
IEnumerable<BlogEntry> items = null) : base(username) {
if (Count>0) {
if (!(ConcernsAUniqueTitle && ConcernsAUniqueTitle))
throw new InvalidOperationException ();
this.AddRange (items);
}
_title = title;
_username = username;
}
private string _title;
private string _username;
public string UserName { get { return _username; } }
/// <summary>
/// Gets the title.
/// </summary>
/// <value>The title.</value>
public string Title { get { return _title; } }
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="Yavsc.Model.Blogs.UUTBlogEntryCollection"/>.</returns>
public override string ToString ()
{
return string.Format ("[UUTBlogEntryCollection: " +
"Title={0} User={1} Count={2}]", Title, UserName, Count);
}
}
}

View File

@ -1,3 +1,48 @@
2015-08-04 Paul Schneider <paul@pschneider.fr>
* BlogEntryCollection.cs: implement the BlogEntryCollection
* BlogManager.cs: the manager helps to filter on access
* BlogProvider.cs: The title is not unique anymore, and one
can modify it, post a lot under it, drop all posts under it.
A Post is deleted by id.
* UUBlogEntryCollection.cs: implements a collection of post
under a given user name.
* UUTBlogEntryCollection.cs: implements a collection of post
under a given couple (user name, title).
* IDbModule.cs:
* WorkFlowManager.cs: refactoring
* ListItem.cs: ListItem is declared obsolete in this model,
helpers can build MVC SelectListItem on data returned by the
manager.
* LocalizedText.Designer.cs:
* LocalizedText.fr.Designer.cs: autogenerated from xml
* LocalizedText.resx:
* LocalizedText.fr.resx: new labels
* ChangeUserNameProvider.cs: xml doc
* Profile.cs: the UserName property is read only, and comes
from authentication, to change it, we set a Name and validate
it agains the "Profile" method
* UserManager.cs: simpler code a init time
* IContentProvider.cs: implements the new IDataProvider
interface
* IDataProvider.cs: defines the new IDataProvider interface
* YavscModel.csproj: includes new classes
2015-07-17 Paul Schneider <paul@pschneider.fr>
* YavscModel.csproj:

View File

@ -9,7 +9,7 @@ namespace Yavsc.Model
/// <summary>
/// I module.
/// </summary>
public interface IModule
public interface IDbModule
{
/// <summary>
/// Install the model in database using the specified cnx.

View File

@ -25,6 +25,7 @@ namespace Yavsc.Model
/// <summary>
/// List item.
/// </summary>
[Obsolete("Use MVC SelectItem")]
public class ListItem
{
/// <summary>

View File

@ -46,6 +46,12 @@ namespace Yavsc.Model {
}
}
public static string Bill_edition {
get {
return ResourceManager.GetString("Bill_edition", resourceCulture);
}
}
public static string Tex_version {
get {
return ResourceManager.GetString("Tex_version", resourceCulture);
@ -286,12 +292,6 @@ namespace Yavsc.Model {
}
}
public static string Bill_edition {
get {
return ResourceManager.GetString("Bill edition", resourceCulture);
}
}
public static string Offline {
get {
return ResourceManager.GetString("Offline", resourceCulture);
@ -334,12 +334,30 @@ namespace Yavsc.Model {
}
}
public static string DisplayName {
get {
return ResourceManager.GetString("DisplayName", resourceCulture);
}
}
public static string Consultant {
get {
return ResourceManager.GetString("Consultant", resourceCulture);
}
}
public static string InternalServerError {
get {
return ResourceManager.GetString("InternalServerError", resourceCulture);
}
}
public static string entries {
get {
return ResourceManager.GetString("entries", resourceCulture);
}
}
public static string DuplicateUserName {
get {
return ResourceManager.GetString("DuplicateUserName", resourceCulture);

View File

@ -46,6 +46,12 @@ namespace Yavsc.Model {
}
}
public static string Bill_edition {
get {
return ResourceManager.GetString("Bill_edition", resourceCulture);
}
}
public static string Tex_version {
get {
return ResourceManager.GetString("Tex_version", resourceCulture);
@ -280,12 +286,6 @@ namespace Yavsc.Model {
}
}
public static string Bill_edition {
get {
return ResourceManager.GetString("Bill edition", resourceCulture);
}
}
public static string Offline {
get {
return ResourceManager.GetString("Offline", resourceCulture);
@ -328,10 +328,28 @@ namespace Yavsc.Model {
}
}
public static string DisplayName {
get {
return ResourceManager.GetString("DisplayName", resourceCulture);
}
}
public static string Consultant {
get {
return ResourceManager.GetString("Consultant", resourceCulture);
}
}
public static string InternalServerError {
get {
return ResourceManager.GetString("InternalServerError", resourceCulture);
}
}
public static string entries {
get {
return ResourceManager.GetString("entries", resourceCulture);
}
}
}
}

View File

@ -59,8 +59,11 @@
<data name="EventWebPage"><value>Page web de l'événement</value></data>
<data name="ImgLocator"><value>URI de l'image</value></data>
<data name="Home"><value>Accueil</value></data>
<data name="Bill edition"><value>Édition d'un billet</value></data>
<data name="Bill_edition"><value>Édition d'un billet</value></data>
<data name="Create"><value>Créer</value></data>
<data name="Members"><value>Membres</value></data>
<data name="UserName"><value>Nom d'utilisateur</value></data>
<data name="DisplayName"><value>Nom affiché</value></data>
<data name="entries"><value>entrées</value></data>
<data name="InternalServerError"><value>Erreur serveur interne</value></data>
</root>

View File

@ -61,8 +61,12 @@
<data name="EventWebPage"><value>Event Web page</value></data>
<data name="ImgLocator"><value>Image URI</value></data>
<data name="Home"><value>Home</value></data>
<data name="Bill edition"><value>Bill edition</value></data>
<data name="Bill_edition"><value>Bill edition</value></data>
<data name="Create"><value>Create</value></data>
<data name="Members"><value>Members</value></data>
<data name="UserName"><value>User Name</value></data>
<data name="DisplayName"><value>Display Name</value></data>
<data name="entries"><value>entries</value></data>
<data name="InternalServerError"><value>Internal Server Error</value></data>
</root>

View File

@ -37,9 +37,17 @@ namespace Yavsc.Model.RolesAndMembers
{
}
/// <summary>
/// Changes the name.
/// </summary>
/// <param name="oldName">Old name.</param>
/// <param name="newName">New name.</param>
public abstract void ChangeName (string oldName, string newName) ;
/// <summary>
/// Determines whether this instance is name available the specified name.
/// </summary>
/// <returns><c>true</c> if this instance is name available the specified name; otherwise, <c>false</c>.</returns>
/// <param name="name">Name.</param>
public abstract bool IsNameAvailable(string name);
}

View File

@ -213,11 +213,13 @@ namespace Yavsc.Model.RolesAndMembers
&& string.IsNullOrWhiteSpace (Mobile));
}
}
private string userName;
/// <summary>
/// Gets or sets the name of the user.
/// </summary>
/// <value>The name of the user.</value>
public string UserName { get ; set; }
public string UserName { get { return userName; } }
public Profile () : base ()
{
@ -268,7 +270,7 @@ namespace Yavsc.Model.RolesAndMembers
s = profile.GetPropertyValue ("Mobile");
Mobile = (s is DBNull) ? null : (string)s;
UserName = profile.UserName;
userName = profile.UserName;
s = profile.GetPropertyValue ("BankCode");
BankCode = (s is DBNull) ? null : (string)s;

View File

@ -1,22 +1,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.Configuration;
using System.Web.Profile;
using System.Web.Security;
using Yavsc;
using Yavsc.Model.RolesAndMembers;
using Yavsc.Helpers;
using System.Web.Mvc;
using Yavsc.Model.Circles;
using System.Collections.Specialized;
using Yavsc.Model;
using System.Configuration;
using System.Reflection;
using System;
namespace Yavsc.Controllers
namespace Yavsc.Model.RolesAndMembers
{
/// <summary>
/// User manager.
@ -52,19 +38,27 @@ namespace Yavsc.Controllers
/// <value>The provider.</value>
public static ChangeUserNameProvider Provider {
get {
if (provider == null)
provider = GetProvider ();
if (provider == null)
throw new ConfigurationErrorsException ("No username section defined");
return provider;
}
}
private static ChangeUserNameProvider GetProvider ()
{
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as DataProviderConfigurationSection;
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/userNameManager") as DataProviderConfigurationSection;
if (config == null)
throw new ConfigurationErrorsException("The configuration bloc for the blog provider was not found");
ProviderSettings celt =
config.Providers[config.DefaultProvider];
if (config == null)
throw new ConfigurationErrorsException("The default blog provider was not found");
throw new ConfigurationErrorsException("The configuration bloc for the username provider was not found");
ProviderSettings celt=null;
if (config.DefaultProvider!=null)
celt = config.Providers[config.DefaultProvider];
if ((celt == null) && config.Providers!=null)
if (config.Providers.Count>0)
celt = config.Providers [0];
if (celt == null)
throw new ConfigurationErrorsException("The default username provider was not found");
ConstructorInfo ci = Type.GetType (celt.Type).GetConstructor (Type.EmptyTypes);
provider = ci.Invoke (Type.EmptyTypes) as ChangeUserNameProvider;
provider.Initialize (celt.Name, celt.Parameters);

View File

@ -8,7 +8,7 @@ namespace Yavsc.Model.WorkFlow
/// Interface content provider.
/// Class Assertion: <c>Statuses.Length &gt;= FinalStatuses.Length</c>.
/// </summary>
public interface IContentProvider : IModule, IDisposable
public interface IContentProvider : IDbModule, IDisposable, IDataProvider<Estimate>
{
/// <summary>
@ -55,12 +55,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="count">Cost multiplier.</param>
/// <param name="productid">Product identifier.</param>
long Write (long estid, string desc, decimal ucost, int count, string productid);
/// <summary>
/// Gets the estimate by identifier.
/// </summary>
/// <returns>The estimate.</returns>
/// <param name="estimid">Estimid.</param>
Estimate GetEstimate (long estimid);
/// <summary>
/// Gets the estimates created by
/// or for the given user by user name.
@ -103,11 +98,6 @@ namespace Yavsc.Model.WorkFlow
/// <param name="wr">Wr.</param>
void UpdateWritting (Writting wr);
/// <summary>
/// Updates the estimate.
/// </summary>
/// <param name="estim">Estim.</param>
void UpdateEstimate (Estimate estim);
/// <summary>
/// Sets the writting status.
/// </summary>
/// <param name="wrtid">Wrtid.</param>

View File

@ -4,8 +4,10 @@ using Yavsc.Model.FrontOffice;
namespace Yavsc.Model.WorkFlow
{
public interface IDataProvider
public interface IDataProvider<T>
{
T Get (long id);
void Update (T data);
}
}

View File

@ -36,7 +36,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estim">Estim.</param>
public void UpdateEstimate (Estimate estim)
{
ContentProvider.UpdateEstimate (estim);
ContentProvider.Update (estim);
}
/// <summary>
/// Gets the estimate.
@ -45,7 +45,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estid">Estid.</param>
public Estimate GetEstimate (long estid)
{
return ContentProvider.GetEstimate (estid);
return ContentProvider.Get (estid);
}
/// <summary>
/// Gets the estimates, refering the

View File

@ -57,7 +57,6 @@
<Compile Include="Blogs\Comment.cs" />
<Compile Include="Blogs\FindBlogEntryFlags.cs" />
<Compile Include="WorkFlow\StatusChange.cs" />
<Compile Include="IModule.cs" />
<Compile Include="Blogs\BlogManager.cs" />
<Compile Include="Blogs\BlogProvider.cs" />
<Compile Include="WorkFlow\WorkFlowManager.cs" />
@ -163,6 +162,13 @@
<Compile Include="WorkFlow\TaskOutput.cs" />
<Compile Include="WorkFlow\FinalStateException.cs" />
<Compile Include="WorkFlow\InvalidLetterException.cs" />
<Compile Include="Blogs\UUTBlogEntryCollection.cs" />
<Compile Include="Blogs\UUBlogEntryCollection.cs" />
<Compile Include="IDbModule.cs" />
<Compile Include="WorkFlow\IDataProvider.cs" />
<Compile Include="Blogs\PostNotFoundException.cs" />
<Compile Include="RolesAndMembers\ChangeUserNameProvider.cs" />
<Compile Include="RolesAndMembers\UserManager.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>