Hallo now edits my images,

and each post can display a dedicated photo.

* NpgsqlBlogProvider.cs: implements a blog post photo storage

* BlogsController.cs: implements a method to update the photo url

* style.css: yastyle

* AdminController.cs: refactoring the notification:
Introduces a static `Notice` method, server side, to populate an array
in `ViewData`, used in the paster page.

* BlogsController.cs: Controls the photo update

* YavscHelpers.cs:
* yavsc.circles.js:
* HomeController.cs:
* GoogleController.cs: notification refactoring

* App.master: - notification refactoring
- html structure in the `nav`

* hallo.js: event 'hallomodified' now also occurs at image
  modifications

* to-markdown.js: ?Fixes? html images alt text and title to Markdown

* yavsc.js: implements the photo in database

* Edit.aspx: A nicer bill edition, with a photo

* UserPost.aspx: Displays the photo

* UserPosts.aspx: Fixes the new usage of `ResultPages`

* Web.config: totem custo

* instdbws.sql: adds a `photo` field in the `blog` table

* BlogEntry.cs: defines the photo in the model

* BlogManager.cs: a new method to set the photo on a blog post.

* BlogProvider.cs: the blog provider now also gives some photo

* LocalizedText.fr.Designer.cs: Reordering the french localisation
  resource

* LocalizedText.fr.resx: Reorders the french localisation resource
This commit is contained in:
Paul Schneider
2015-10-08 12:43:04 +02:00
parent 303e4fa57b
commit 9494d6f353
26 changed files with 773 additions and 586 deletions

View File

@ -0,0 +1,4 @@
2015-10-08 Paul Schneider <paul@pschneider.fr>
* NpgsqlBlogProvider.cs: implements a blog post photo storage

View File

@ -236,7 +236,7 @@ namespace Npgsql.Web.Blog
BlogEntry be = null;
using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand()) {
cmd.CommandText = "select username, title, bcontent, modified, posted, visible from blog " +
cmd.CommandText = "select username, title, bcontent, modified, posted, visible, photo from blog " +
"where applicationname = @appname and _id = @id";
cmd.Parameters.AddWithValue ("@appname", applicationName);
cmd.Parameters.AddWithValue ("@id", postid);
@ -250,6 +250,7 @@ namespace Npgsql.Web.Blog
be.Modified = rdr.GetDateTime (rdr.GetOrdinal ("modified"));
be.Posted = rdr.GetDateTime (rdr.GetOrdinal ("posted"));
be.Visible = rdr.GetBoolean (rdr.GetOrdinal ("visible"));
be.Photo = rdr.GetString (rdr.GetOrdinal ("photo"));
be.Id = postid;
}
}
@ -285,7 +286,7 @@ namespace Npgsql.Web.Blog
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 " +
cmd.CommandText = "select _id,bcontent,modified,posted,visible,photo from blog " +
"where applicationname = :appname and username = :username and title = :title";
cmd.Parameters.AddWithValue ("appname", NpgsqlDbType.Varchar, applicationName);
cmd.Parameters.AddWithValue ("username", NpgsqlDbType.Varchar ,username);
@ -302,6 +303,7 @@ namespace Npgsql.Web.Blog
be.Posted = rdr.GetDateTime (rdr.GetOrdinal ("posted"));
be.Visible = rdr.GetBoolean (rdr.GetOrdinal ("visible"));
be.Id = rdr.GetInt64 (rdr.GetOrdinal ("_id"));
be.Photo = rdr.GetString (rdr.GetOrdinal ("photo"));
bec.Add (be);
}
rdr.Close ();
@ -393,6 +395,24 @@ namespace Npgsql.Web.Blog
UpdatePostCircles (pid, circles);
return pid;
}
/// <summary>
/// Updates the post photo.
/// </summary>
/// <param name="pid">Pid.</param>
/// <param name="photo">Photo.</param>
public override void UpdatePostPhoto ( long pid, string photo)
{
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) {
cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "update blog set photo = :photo where _id = :pid";
cmd.Parameters.AddWithValue ("pid", pid);
cmd.Parameters.AddWithValue ("photo", photo);
cmd.ExecuteNonQuery ();
}
cnx.Close ();
}
}
private void UpdatePostCircles( long pid, long[] circles)
{

View File

@ -125,10 +125,29 @@ namespace Yavsc.ApiControllers
}
}
/// <summary>
/// Searchs the files accociated to the given post id,
/// or related to the given terms.
/// </summary>
/// <returns>The file.</returns>
/// <param name="postid">Postid.</param>
/// <param name="terms">Terms.</param>
[Authorize,HttpGet]
public async Task<HttpResponseMessage> SearchFile(long postid, string terms) {
throw new NotImplementedException ();
}
/// <summary>
/// Sets the photo.
/// </summary>
/// <param name="id">Identifier.</param>
/// <param name="photo">Photo.</param>
[Authorize,HttpPost]
public void SetPhoto(long id, string photo)
{
BlogManager.Provider.UpdatePostPhoto (id, photo);
}
/// <summary>
/// Import the specified id.
/// </summary>
@ -138,7 +157,7 @@ namespace Yavsc.ApiControllers
throw new HttpRequestException ("not a multipart/form-data request");
BlogEntry be = BlogManager.GetPost (id);
if (be.Author != Membership.GetUser ().UserName)
throw new AuthorizationDenied ("b"+id);
throw new AuthorizationDenied ("post: "+id);
string root = HttpContext.Current.Server.MapPath("~/bfiles/"+id);
DirectoryInfo di = new DirectoryInfo (root);
if (!di.Exists) di.Create ();
@ -150,7 +169,7 @@ namespace Yavsc.ApiControllers
var invalidChars = Path.GetInvalidFileNameChars();
List<string> bodies = new List<string>();
foreach (string fkey in provider.BodyPartFileNames.Keys)
{
string filename = provider.BodyPartFileNames[fkey];

View File

@ -75,7 +75,7 @@ a.actionlink img, h1 img, .menuitem img { vertical-align: middle; }
border-radius:5px;
margin:.5em; padding:1em; display: inline-block }
fieldset {
background-color: rgba(32,16,16,0.8);
background-color: rgba(16,16,64,0.8);
border-radius:5px; border: solid 1px #000060;
}
@ -96,7 +96,7 @@ aside {
max-width: 40em;
padding: .5em;
margin: .5em;
background-color: rgba(32,32,32,0.8);
background-color: rgba(0,0,32,0.8);
border-radius:10px;
}
.postpreview video, .postpreview img {
@ -107,7 +107,7 @@ aside {
display:block;
margin:1em;
padding:1em;
background-color: rgba(32,32,32,0.8);
background-color: rgba(0,0,32,0.8);
color: #aaa;
border-radius:10px;
}
@ -125,7 +125,7 @@ textarea.fullwidth { min-height:10em; }
}
.panel,.bshpanel, aside {
background-color: rgba(32,32,16,0.8);
background-color: rgba(0,0,128,.5);
border-radius:5px;
margin:.5em;
padding: .5em;
@ -167,9 +167,14 @@ label {
font-size: medium;
}
.message, #message {
#notifications {
padding: .5em;
}
.notification {
font-size: large;
background-color: rgba(64,64,0,0.5);
border: solid green 1px;
}
.dirty {
background-color: rgba(128,128,0,0.5);
@ -184,7 +189,6 @@ label {
background-color: rgba(256,0,0,0.5);
}
.hidden { display:none; }
ul.preview li:nth-child(-n+10) {
@ -234,6 +238,9 @@ input, select {
max-width: 64px;
max-height: 64px;
}
#avatar {
float: left;
}
.comment {
border-radius:25px;
@ -268,8 +275,7 @@ input, select {
.c3 { font-size: x-small; font-style: italic; }
@media print {
body {background-color:white;color:black;}
header,footer,.postcomment,.actionlink,nav
{ display:none;}
.control,.actionlink,nav { display:none;}
}
@media all and (min-width: 640px) {

40
web/ChangeLog Normal file
View File

@ -0,0 +1,40 @@
2015-10-08 Paul Schneider <paul@pschneider.fr>
* BlogsController.cs: implements a method to update the photo
url
* style.css: yastyle
* AdminController.cs: refactoring the notification:
Introduces a static `Notice` method, server side, to populate
an array
in `ViewData`, used in the paster page.
* BlogsController.cs: Controls the photo update
* YavscHelpers.cs:
* yavsc.circles.js:
* HomeController.cs:
* GoogleController.cs: notification refactoring
* App.master: - notification refactoring
- html structure in the `nav`
* hallo.js: event 'hallomodified' now also occurs at image
modifications
* to-markdown.js: ?Fixes? html images alt text and title to
Markdown
* yavsc.js: implements the photo in database
* Edit.aspx: A nicer bill edition, with a photo
* UserPost.aspx: Displays the photo
* UserPosts.aspx: Fixes the new usage of `ResultPages`
* Web.config: totem custo
* instdbws.sql: adds a `photo` field in the `blog` table

View File

@ -10,6 +10,7 @@ using Yavsc.Model.Admin;
using Yavsc.Admin;
using System.IO;
using Yavsc.Model;
using Yavsc.Helpers;
namespace Yavsc.Controllers
{
@ -160,8 +161,7 @@ namespace Yavsc.Controllers
ViewData ["usertoremove"] = username;
if (submitbutton == "Supprimer") {
Membership.DeleteUser (username);
ViewData["Message"]=
string.Format("utilisateur \"{0}\" supprimé",username);
YavscHelpers.Notice(ViewData, string.Format("utilisateur \"{0}\" supprimé",username));
ViewData ["usertoremove"] = null;
}
return View ();
@ -236,7 +236,7 @@ namespace Yavsc.Controllers
public ActionResult DoAddRole (string rolename)
{
Roles.CreateRole(rolename);
ViewData["Message"] = LocalizedText.role_created+ " : "+rolename;
YavscHelpers.Notice(ViewData, LocalizedText.role_created+ " : "+rolename);
return View ();
}
@ -274,7 +274,7 @@ namespace Yavsc.Controllers
ViewData ["useritems"] = users;
if (ModelState.IsValid) {
Roles.AddUserToRole (model.UserName, adminRoleName);
ViewData ["Message"] = model.UserName + " "+LocalizedText.was_added_to_the_role+" '" + adminRoleName + "'";
YavscHelpers.Notice(ViewData, model.UserName + " "+LocalizedText.was_added_to_the_role+" '" + adminRoleName + "'");
} else {
if (admins.Length > 0) {
if (! admins.Contains (Membership.GetUser ().UserName)) {
@ -286,9 +286,9 @@ namespace Yavsc.Controllers
// No admin, gives the Admin Role to the current user
Roles.AddUserToRole (currentUser, adminRoleName);
admins = new string[] { currentUser };
ViewData ["Message"] += string.Format (
YavscHelpers.Notice(ViewData, string.Format (
LocalizedText.was_added_to_the_empty_role,
currentUser, adminRoleName);
currentUser, adminRoleName));
}
}
return View (model);

View File

@ -273,6 +273,8 @@ namespace Yavsc.Controllers
}
else
model.Id = BlogManager.Post (model.Author, model.Title, model.Content, model.Visible, model.AllowedCircles);
if (model.Photo != null)
BlogManager.UpdatePostPhoto (model.Id, model.Photo);
return RedirectToAction ("UserPosts", new { user = model.Author, title = model.Title });
}
ViewData ["AllowedCircles"] =

View File

@ -17,6 +17,7 @@ using Yavsc.Model.Google;
using Yavsc.Model.RolesAndMembers;
using Yavsc.Helpers.Google;
using Yavsc.Model.Calendar;
using Yavsc.Helpers;
namespace Yavsc.Controllers
{
@ -100,7 +101,7 @@ namespace Yavsc.Controllers
AuthToken gat = oa.GetToken (Request, (string)Session ["state"], out msg);
if (gat == null) {
ViewData ["Message"] = msg;
YavscHelpers.Notice(ViewData, msg);
return View ("Auth");
}
SaveToken (gat);
@ -137,7 +138,7 @@ namespace Yavsc.Controllers
OAuth2 oa = new OAuth2 (AuthGRU);
AuthToken gat = oa.GetToken (Request, (string)Session ["state"], out msg);
if (gat == null) {
ViewData ["Message"] = msg;
YavscHelpers.Notice(ViewData, msg);
return View ();
}
string returnUrl = (string)Session ["returnUrl"];

View File

@ -84,16 +84,9 @@ namespace Yavsc.Controllers
/// </summary>
public ActionResult Index ()
{
/*
* A very bad idea (a redirect permanent as home page):
*
* string startPage = WebConfigurationManager.AppSettings ["StartPage"];
if (startPage != null)
Redirect (startPage);
*/
ViewData ["Message"] = LocalizedText.Welcome;
return View ();
}
/// <summary>
/// Contact the specified email, reason and body.
/// </summary>
@ -123,8 +116,7 @@ namespace Yavsc.Controllers
using (System.Net.Mail.SmtpClient sc = new SmtpClient())
{
sc.Send (msg);
ViewData ["Message"] = LocalizedText.Message_sent;
YavscHelpers.Notice(ViewData, LocalizedText.Message_sent);
return View (new { email=email, reason="", body="" });
}
}

View File

@ -14,6 +14,7 @@ using Yavsc.Model.Circles;
using System.Web.UI;
using System.Linq.Expressions;
using System.Web.Profile;
using System.Web.Script.Serialization;
namespace Yavsc.Helpers
{
@ -175,6 +176,23 @@ namespace Yavsc.Helpers
if (a == null || a is DBNull) return "/avatars/" + helper.Encode(username)+".png";
return helper.Encode ((string)a);
}
public static string JavaScript(this HtmlHelper html, object obj)
{
return JavaScript (obj);
}
public static string JavaScript(object obj)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);
}
public static void Notice (ViewDataDictionary ViewData, string message) {
if (ViewData ["Notifications"] == null)
ViewData ["Notifications"] = new List<string> ();
(ViewData ["Notifications"] as List<string>).Add (message.Replace("\'","\\\'"));
}
}
}

View File

@ -22,7 +22,6 @@ var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
<script src="/Scripts/yavsc.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'/>
</head>
<body>
<header data-type="background" data-speed="8" >
@ -34,26 +33,33 @@ var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
</span></h1>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="header" runat="server"></asp:ContentPlaceHolder>
<div id="error"><%= (ViewData["Error"]!=null)? Html.Encode(ViewData["Error"]) : "" %></div>
<div id="message"><%= Html.Encode(ViewData["Message"]) %></div>
<div id="notifications">
</div>
<%if (ViewData ["Notifications"]!=null) { %>
<script>
$(document).ready(function(){
<% foreach (string notice in (IEnumerable<string>) ViewData ["Notifications"] ) { %>
Yavsc.notice('<%=notice%>');
<% } %>
});
</script>
<% } %>
</header>
<nav data-type="background" data-speed="2">
<% if (Membership.GetUser()==null) { %>
<a href="<%= Url.Content("~/Account/Login/?returnUrl=") + Url.Encode( Request.Url.PathAndQuery )%>" >
<div class="menuitem">
<i class="fa fa-sign-in"></i> Connexion
</div>
<a href="<%= Url.Content("~/Account/Login/?returnUrl=") + Url.Encode( Request.Url.PathAndQuery )%>" class="menuitem" >
<i class="fa fa-sign-in">Connexion</i>
</a>
<% } else { %>
<a href="/Blog/<%= HttpContext.Current.User.Identity.Name%>" accesskey = "B" >
<div class="menuitem">
<a href="/Blog/<%= HttpContext.Current.User.Identity.Name%>" accesskey = "B" class="menuitem" >
<img src="<%=Html.AvatarUrl(HttpContext.Current.User.Identity.Name)%>" alt="vos billets" class="iconsmall" />
<div class="hint">Vos billets</div>
</div>
<span class="hint">Vos billets</span>
</a>
<a href="<%= Url.Content("~/Account/Profile/" + HttpContext.Current.User.Identity.Name) %>" accesskey="L" class="menuitem">
<i class="fa fa-user"><%= HttpContext.Current.User.Identity.Name %>
<div class="hint"> &Eacute;dition de votre profile </div></i>
<span class="hint"> &Eacute;dition de votre profile </span></i>
</a>
<a href="/Blogs/Post" accesskey="P" class="menuitem">
<i class="fa fa-pencil"><u>P</u>oster
@ -76,6 +82,7 @@ var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
<div id="copyr">
© 2012 Totem Production. Tous droits réservés.
</div>
<div class="control">
<p>
<%= Html.ActionLink("Formulaire de contact","Contact","Home") %>
</p>
@ -88,6 +95,7 @@ var apiBaseUrl = '<%=Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative)%>';
</script>
<div id="gspacer"><div class="g-plusone" data-annotation="inline" data-width="170"></div>
</div>
</div>
</footer>
</body>
</html>

View File

@ -1771,373 +1771,6 @@ http://hallojs.org
});
})(jQuery);
(function(jQuery) {
return jQuery.widget("IKS.hallo-image-insert-edit", {
options: {
editable: null,
toolbar: null,
uuid: "",
insert_file_dialog_ui_url: null,
lang: 'en',
dialogOpts: {
autoOpen: false,
width: 560,
height: 'auto',
modal: false,
resizable: true,
draggable: true,
dialogClass: 'insert-image-dialog'
},
dialog: null,
buttonCssClass: null
},
translations: {
en: {
title_insert: 'Insert Image',
title_properties: 'Image Properties',
insert: 'Insert',
chage_image: 'Change Image:',
source: 'URL',
width: 'Width',
height: 'Height',
alt: 'Alt Text',
padding: 'Padding',
txt_float: 'Float',
float_left: 'left',
float_right: 'right',
float_none: 'No'
},
de: {
title_insert: 'Bild einfügen',
title_properties: 'Bildeigenschaften',
insert: 'Einfügen',
chage_image: 'Bild ändern:',
source: 'URL',
width: 'Breite',
height: 'Höhe',
alt: 'Alt Text',
padding: 'Padding',
txt_float: 'Float',
float_left: 'Links',
float_right: 'Rechts',
float_none: 'Nein'
},
fr: {
title_insert: 'Inserer une image',
title_properties: 'Propriétés de l\'image',
insert: 'Inserer',
chage_image: 'Changer d\'image:',
source: 'URL',
width: 'Largeur',
height: 'Hauteur',
alt: 'Texte alternatif',
padding: 'Encadrement',
txt_float: 'Flotaison',
float_left: 'gauche',
float_right: 'droite',
float_none: 'non'
}
},
texts: null,
dialog_image_selection_ui_loaded: false,
$image: null,
populateToolbar: function($toolbar) {
var $buttonHolder, $buttonset, dialog_html, widget;
widget = this;
this.texts = this.translations[this.options.lang];
this.options.toolbar = $toolbar;
dialog_html = "<div id='hallo_img_properties'></div>";
if (this.options.insert_file_dialog_ui_url) {
dialog_html += "<div id='hallo_img_file_select_ui'></div>";
}
this.options.dialog = jQuery("<div>").attr('id', this.options.uuid + "-insert-image-dialog").html(dialog_html);
$buttonset = jQuery("<span>").addClass(this.widgetName);
$buttonHolder = jQuery('<span>');
$buttonHolder.hallobutton({
label: this.texts.title_insert,
icon: 'fa-picture-o',
editable: this.options.editable,
command: null,
queryState: false,
uuid: this.options.uuid,
cssClass: this.options.buttonCssClass
});
$buttonset.append($buttonHolder);
this.button = $buttonHolder;
this.button.click(function() {
if (widget.options.dialog.dialog("isOpen")) {
widget._closeDialog();
} else {
widget.lastSelection = widget.options.editable.getSelection();
widget._openDialog();
}
return false;
});
this.options.editable.element.on("halloselected, hallounselected", function() {
if (widget.options.dialog.dialog("isOpen")) {
return widget.lastSelection = widget.options.editable.getSelection();
}
});
this.options.editable.element.on("hallodeactivated", function() {
return widget._closeDialog();
});
jQuery(this.options.editable.element).on("click", "img", function(e) {
widget._openDialog(jQuery(this));
return false;
});
this.options.editable.element.on('halloselected', function(event, data) {
var toolbar_option;
toolbar_option = widget.options.editable.options.toolbar;
if (toolbar_option === "halloToolbarContextual" && jQuery(data.originalEvent.target).is('img')) {
$toolbar.hide();
return false;
}
});
$toolbar.append($buttonset);
return this.options.dialog.dialog(this.options.dialogOpts);
},
_openDialog: function($image) {
var $editableEl, widget, xposition, yposition;
this.$image = $image;
widget = this;
$editableEl = jQuery(this.options.editable.element);
xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
if (this.$image) {
yposition = this.$image.offset().top - jQuery(document).scrollTop();
} else {
yposition = this.options.toolbar.offset().top - jQuery(document).scrollTop();
}
this.options.dialog.dialog("option", "position", [xposition, yposition]);
this.options.editable.keepActivated(true);
this.options.dialog.dialog("open");
if (this.$image) {
this.options.dialog.dialog("option", "title", this.texts.title_properties);
jQuery(document).keyup(function(e) {
if (e.keyCode === 46 || e.keyCode === 8) {
jQuery(document).off();
widget._closeDialog();
widget.$image.remove();
widget.$image = null;
}
return e.preventDefault();
});
this.options.editable.element.on("click", function() {
widget.$image = null;
return widget._closeDialog();
});
} else {
this.options.dialog.children('#hallo_img_properties').hide();
this.options.dialog.dialog("option", "title", this.texts.title_insert);
if (jQuery('#hallo_img_file_select_title').length > 0) {
jQuery('#hallo_img_file_select_title').text('');
}
}
this._load_dialog_image_properties_ui();
this.options.dialog.on('dialogclose', (function(_this) {
return function() {
var scrollbar_pos;
jQuery('label', _this.button).removeClass('ui-state-active');
scrollbar_pos = jQuery(document).scrollTop();
_this.options.editable.element.focus();
jQuery(document).scrollTop(scrollbar_pos);
return _this.options.editable.keepActivated(false);
};
})(this));
if (this.options.insert_file_dialog_ui_url && !this.dialog_image_selection_ui_loaded) {
this.options.dialog.on('click', ".reload_link", function() {
widget._load_dialog_image_selection_ui();
return false;
});
this.options.dialog.on('click', '.file_preview img', function() {
var new_source;
if (widget.$image) {
new_source = jQuery(this).attr('src').replace(/-thumb/, '');
widget.$image.attr('src', new_source);
jQuery('#hallo_img_source').val(new_source);
} else {
widget._insert_image(jQuery(this).attr('src').replace(/-thumb/, ''));
}
return false;
});
return this._load_dialog_image_selection_ui();
}
},
_insert_image: function(source) {
this.options.editable.restoreSelection(this.lastSelection);
document.execCommand("insertImage", null, source);
this.options.editable.element.trigger('change');
this.options.editable.removeAllSelections();
return this._closeDialog();
},
_closeDialog: function() {
return this.options.dialog.dialog("close");
},
_load_dialog_image_selection_ui: function() {
var widget;
widget = this;
return jQuery.ajax({
url: this.options.insert_file_dialog_ui_url,
success: function(data, textStatus, jqXHR) {
var $properties, file_select_title, t;
file_select_title = '';
$properties = widget.options.dialog.children('#hallo_img_properties');
if ($properties.is(':visible')) {
file_select_title = widget.texts.change_image;
}
t = "<div id='hallo_img_file_select_title'>" + file_select_title + "</div>";
widget.options.dialog.children('#hallo_img_file_select_ui').html(t + data);
return widget.dialog_image_selection_ui_loaded = true;
},
beforeSend: function() {
return widget.options.dialog.children('#hallo_img_file_select_ui').html('<div class="hallo_insert_file_loader"></div>');
}
});
},
_load_dialog_image_properties_ui: function() {
var $img_properties, button, height, html, widget, width;
widget = this;
$img_properties = this.options.dialog.children('#hallo_img_properties');
if (this.$image) {
width = this.$image.is('[width]') ? this.$image.attr('width') : '';
height = this.$image.is('[height]') ? this.$image.attr('height') : '';
html = this._property_input_html('source', this.$image.attr('src'), {
label: this.texts.source
}) + this._property_input_html('alt', this.$image.attr('alt') || '', {
label: this.texts.alt
}) + this._property_row_html(this._property_input_html('width', width, {
label: this.texts.width,
row: false
}) + this._property_input_html('height', height, {
label: this.texts.height,
row: false
})) + this._property_input_html('padding', this.$image.css('padding'), {
label: this.texts.padding
}) + this._property_row_html(this._property_cb_html('float_left', this.$image.css('float') === 'left', {
label: this.texts.float_left,
row: false
}) + this._property_cb_html('float_right', this.$image.css('float') === 'right', {
label: this.texts.float_right,
row: false
}) + this._property_cb_html('unfloat', this.$image.css('float') === 'none', {
label: this.texts.float_none,
row: false
}), this.texts.txt_float);
$img_properties.html(html);
$img_properties.show();
} else {
if (!this.options.insert_file_dialog_ui_url) {
$img_properties.html(this._property_input_html('source', '', {
label: this.texts.source
}));
$img_properties.show();
}
}
if (this.$image) {
if (!this.options.insert_file_dialog_ui_url) {
jQuery('#insert_image_btn').remove();
}
if (jQuery('#hallo_img_file_select_title').length > 0) {
jQuery('#hallo_img_file_select_title').text(this.texts.chage_image);
}
jQuery('#hallo_img_properties #hallo_img_source').keyup(function() {
return widget.$image.attr('src', this.value);
});
jQuery('#hallo_img_properties #hallo_img_alt').keyup(function() {
return widget.$image.attr('alt', this.value);
});
jQuery('#hallo_img_properties #hallo_img_padding').keyup(function() {
return widget.$image.css('padding', this.value);
});
jQuery('#hallo_img_properties #hallo_img_height').keyup(function() {
widget.$image.css('height', this.value);
return widget.$image.attr('height', this.value);
});
jQuery('#hallo_img_properties #hallo_img_width').keyup(function() {
widget.$image.css('width', this.value);
return widget.$image.attr('width', this.value);
});
jQuery('#hallo_img_properties #hallo_img_float_left').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'left');
jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
});
jQuery('#hallo_img_properties #hallo_img_float_right').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'right');
jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
});
return jQuery('#hallo_img_properties #hallo_img_unfloat').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'none');
jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
});
} else {
if (!this.options.insert_file_dialog_ui_url) {
button = "<button id=\"insert_image_btn\">" + this.texts.insert + "</button>";
$img_properties.after(button);
return jQuery('#insert_image_btn').click(function() {
var $img_source;
$img_source = jQuery('#hallo_img_properties #hallo_img_source');
return widget._insert_image($img_source.val());
});
}
}
},
_property_col_html: function(col_html) {
return "<div class='hallo_img_property_col'>" + col_html + "</div>";
},
_property_row_html: function(row_html, label) {
if (label == null) {
label = '';
}
row_html = this._property_col_html(label) + this._property_col_html(row_html);
return "<div class='hallo_img_property_row'>" + row_html + "</div>";
},
_property_html: function(property_html, options) {
var entry;
if (options == null) {
options = {};
}
if (options.row === false) {
if (options.label) {
entry = options.label + " " + property_html;
property_html = "<span class='img_property_entry'>" + entry + "</span>";
}
return property_html;
} else {
entry = "<span class='img_property_entry'>" + property_html + "</span>";
return this._property_row_html(entry, options.label);
}
},
_property_input_html: function(id, value, options) {
var text_field;
if (options == null) {
options = {};
}
text_field = "<input type='text' id='hallo_img_" + id + "' value='" + value + "'>";
return this._property_html(text_field, options);
},
_property_cb_html: function(id, checked, options) {
var cb, checked_attr;
if (options == null) {
options = {};
}
checked_attr = checked ? 'checked=checked' : '';
cb = "<input type='checkbox' id='hallo_img_" + id + "' " + checked_attr + "'>";
return this._property_html(cb, options);
}
});
})(jQuery);
(function(jQuery) {
return jQuery.widget('IKS.halloindicator', {
options: {
@ -3183,4 +2816,367 @@ http://hallojs.org
});
})(jQuery);
(function(jQuery) {
return jQuery.widget("IKS.hallo-image-insert-edit", {
options: {
editable: null,
toolbar: null,
uuid: "",
insert_file_dialog_ui_url: null,
lang: 'en',
dialogOpts: {
autoOpen: false,
width: 560,
height: 'auto',
modal: false,
resizable: true,
draggable: true,
dialogClass: 'insert-image-dialog'
},
dialog: null,
buttonCssClass: null
},
translations: {
en: {
title_insert: 'Insert Image',
title_properties: 'Image Properties',
insert: 'Insert',
chage_image: 'Change Image:',
source: 'URL',
width: 'Width',
height: 'Height',
alt: 'Alt Text',
padding: 'Padding',
txt_float: 'Float',
float_left: 'left',
float_right: 'right',
float_none: 'No'
},
de: {
title_insert: 'Bild einfügen',
title_properties: 'Bildeigenschaften',
insert: 'Einfügen',
chage_image: 'Bild ändern:',
source: 'URL',
width: 'Breite',
height: 'Höhe',
alt: 'Alt Text',
padding: 'Padding',
txt_float: 'Float',
float_left: 'Links',
float_right: 'Rechts',
float_none: 'Nein'
},
fr: {
title_insert: 'Inserer une image',
title_properties: 'Propriétés de l\'image',
insert: 'Inserer',
chage_image: 'Changer d\'image:',
source: 'URL',
width: 'Largeur',
height: 'Hauteur',
alt: 'Texte alternatif',
padding: 'Encadrement',
txt_float: 'Flotaison',
float_left: 'gauche',
float_right: 'droite',
float_none: 'non'
}
},
texts: null,
dialog_image_selection_ui_loaded: false,
$image: null,
populateToolbar: function($toolbar) {
var $buttonHolder, $buttonset, dialog_html, widget;
widget = this;
this.texts = this.translations[this.options.lang];
this.options.toolbar = $toolbar;
dialog_html = "<div id='hallo_img_properties'></div>";
if (this.options.insert_file_dialog_ui_url) {
dialog_html += "<div id='hallo_img_file_select_ui'></div>";
}
this.options.dialog = jQuery("<div>").attr('id', this.options.uuid + "-insert-image-dialog").html(dialog_html);
$buttonset = jQuery("<span>").addClass(this.widgetName);
$buttonHolder = jQuery('<span>');
$buttonHolder.hallobutton({
label: this.texts.title_insert,
icon: 'fa-picture-o',
editable: this.options.editable,
command: null,
queryState: false,
uuid: this.options.uuid,
cssClass: this.options.buttonCssClass
});
$buttonset.append($buttonHolder);
this.button = $buttonHolder;
this.button.click(function() {
if (widget.options.dialog.dialog("isOpen")) {
widget._closeDialog();
} else {
widget.lastSelection = widget.options.editable.getSelection();
widget._openDialog();
}
return false;
});
this.options.editable.element.on("halloselected, hallounselected", function() {
if (widget.options.dialog.dialog("isOpen")) {
return widget.lastSelection = widget.options.editable.getSelection();
}
});
this.options.editable.element.on("hallodeactivated", function() {
return widget._closeDialog();
});
jQuery(this.options.editable.element).on("click", "img", function(e) {
widget._openDialog(jQuery(this));
return false;
});
this.options.editable.element.on('halloselected', function(event, data) {
var toolbar_option;
toolbar_option = widget.options.editable.options.toolbar;
if (toolbar_option === "halloToolbarContextual" && jQuery(data.originalEvent.target).is('img')) {
$toolbar.hide();
return false;
}
});
$toolbar.append($buttonset);
return this.options.dialog.dialog(this.options.dialogOpts);
},
_openDialog: function($image) {
var $editableEl, widget, xposition, yposition;
this.$image = $image;
widget = this;
$editableEl = jQuery(this.options.editable.element);
xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10;
if (this.$image) {
yposition = this.$image.offset().top - jQuery(document).scrollTop();
} else {
yposition = this.options.toolbar.offset().top - jQuery(document).scrollTop();
}
this.options.dialog.dialog("option", "position", [xposition, yposition]);
this.options.editable.keepActivated(true);
this.options.dialog.dialog("open");
if (this.$image) {
this.options.dialog.dialog("option", "title", this.texts.title_properties);
this.options.editable.element.on("click", function() {
widget.$image = null;
return widget._closeDialog();
});
} else {
this.options.dialog.children('#hallo_img_properties').hide();
this.options.dialog.dialog("option", "title", this.texts.title_insert);
if (jQuery('#hallo_img_file_select_title').length > 0) {
jQuery('#hallo_img_file_select_title').text('');
}
}
this._load_dialog_image_properties_ui();
this.options.dialog.on('dialogclose', (function(_this) {
return function() {
var scrollbar_pos;
jQuery('label', _this.button).removeClass('ui-state-active');
scrollbar_pos = jQuery(document).scrollTop();
_this.options.editable.element.focus();
jQuery(document).scrollTop(scrollbar_pos);
return _this.options.editable.keepActivated(false);
};
})(this));
if (this.options.insert_file_dialog_ui_url && !this.dialog_image_selection_ui_loaded) {
this.options.dialog.on('click', ".reload_link", function() {
widget._load_dialog_image_selection_ui();
return false;
});
this.options.dialog.on('click', '.file_preview img', function() {
var new_source;
if (widget.$image) {
new_source = jQuery(this).attr('src').replace(/-thumb/, '');
widget.$image.attr('src', new_source);
jQuery('#hallo_img_source').val(new_source);
} else {
widget._insert_image(jQuery(this).attr('src').replace(/-thumb/, ''));
}
return false;
});
return this._load_dialog_image_selection_ui();
}
},
_insert_image: function(source) {
this.options.editable.restoreSelection(this.lastSelection);
document.execCommand("insertImage", null, source);
this.options.editable.element.trigger('change');
this.options.editable.removeAllSelections();
return this._closeDialog();
},
_closeDialog: function() {
return this.options.dialog.dialog("close");
},
_load_dialog_image_selection_ui: function() {
var widget;
widget = this;
return jQuery.ajax({
url: this.options.insert_file_dialog_ui_url,
success: function(data, textStatus, jqXHR) {
var $properties, file_select_title, t;
file_select_title = '';
$properties = widget.options.dialog.children('#hallo_img_properties');
if ($properties.is(':visible')) {
file_select_title = widget.texts.change_image;
}
t = "<div id='hallo_img_file_select_title'>" + file_select_title + "</div>";
widget.options.dialog.children('#hallo_img_file_select_ui').html(t + data);
return widget.dialog_image_selection_ui_loaded = true;
},
beforeSend: function() {
return widget.options.dialog.children('#hallo_img_file_select_ui').html('<div class="hallo_insert_file_loader"></div>');
}
});
},
_load_dialog_image_properties_ui: function() {
var $img_properties, button, height, html, widget, width;
widget = this;
$img_properties = this.options.dialog.children('#hallo_img_properties');
if (this.$image) {
width = this.$image.is('[width]') ? this.$image.attr('width') : '';
height = this.$image.is('[height]') ? this.$image.attr('height') : '';
html = this._property_input_html('source', this.$image.attr('src'), {
label: this.texts.source
}) + this._property_input_html('alt', this.$image.attr('alt') || '', {
label: this.texts.alt
}) + this._property_row_html(this._property_input_html('width', width, {
label: this.texts.width,
row: false
}) + this._property_input_html('height', height, {
label: this.texts.height,
row: false
})) + this._property_input_html('padding', this.$image.css('padding'), {
label: this.texts.padding
}) + this._property_row_html(this._property_cb_html('float_left', this.$image.css('float') === 'left', {
label: this.texts.float_left,
row: false
}) + this._property_cb_html('float_right', this.$image.css('float') === 'right', {
label: this.texts.float_right,
row: false
}) + this._property_cb_html('unfloat', this.$image.css('float') === 'none', {
label: this.texts.float_none,
row: false
}), this.texts.txt_float);
$img_properties.html(html);
$img_properties.show();
} else {
if (!this.options.insert_file_dialog_ui_url) {
$img_properties.html(this._property_input_html('source', '', {
label: this.texts.source
}));
$img_properties.show();
}
}
if (this.$image) {
if (!this.options.insert_file_dialog_ui_url) {
jQuery('#insert_image_btn').remove();
}
if (jQuery('#hallo_img_file_select_title').length > 0) {
jQuery('#hallo_img_file_select_title').text(this.texts.chage_image);
}
jQuery('#hallo_img_properties #hallo_img_source').keyup(function() {
widget.$image.attr('src', this.value);
return widget.options.editable.element.trigger('change');
});
jQuery('#hallo_img_properties #hallo_img_alt').keyup(function() {
widget.$image.attr('alt', this.value);
return widget.options.editable.element.trigger('change');
});
jQuery('#hallo_img_properties #hallo_img_padding').keyup(function() {
widget.$image.css('padding', this.value);
return widget.options.editable.element.trigger('change');
});
jQuery('#hallo_img_properties #hallo_img_height').keyup(function() {
widget.$image.css('height', this.value);
widget.$image.attr('height', this.value);
return widget.options.editable.element.trigger('change');
});
jQuery('#hallo_img_properties #hallo_img_width').keyup(function() {
widget.$image.css('width', this.value);
widget.$image.attr('width', this.value);
return widget.options.editable.element.trigger('change');
});
jQuery('#hallo_img_properties #hallo_img_float_left').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'left');
jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
});
jQuery('#hallo_img_properties #hallo_img_float_right').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'right');
jQuery('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
});
return jQuery('#hallo_img_properties #hallo_img_unfloat').click(function() {
if (!this.checked) {
return false;
}
widget.$image.css('float', 'none');
jQuery('#hallo_img_properties #hallo_img_float_right').removeAttr('checked');
return jQuery('#hallo_img_properties #hallo_img_float_left').removeAttr('checked');
});
} else {
if (!this.options.insert_file_dialog_ui_url) {
button = "<button id=\"insert_image_btn\">" + this.texts.insert + "</button>";
$img_properties.after(button);
return jQuery('#insert_image_btn').click(function() {
var $img_source;
$img_source = jQuery('#hallo_img_properties #hallo_img_source');
return widget._insert_image($img_source.val());
});
}
}
},
_property_col_html: function(col_html) {
return "<div class='hallo_img_property_col'>" + col_html + "</div>";
},
_property_row_html: function(row_html, label) {
if (label == null) {
label = '';
}
row_html = this._property_col_html(label) + this._property_col_html(row_html);
return "<div class='hallo_img_property_row'>" + row_html + "</div>";
},
_property_html: function(property_html, options) {
var entry;
if (options == null) {
options = {};
}
if (options.row === false) {
if (options.label) {
entry = options.label + " " + property_html;
property_html = "<span class='img_property_entry'>" + entry + "</span>";
}
return property_html;
} else {
entry = "<span class='img_property_entry'>" + property_html + "</span>";
return this._property_row_html(entry, options.label);
}
},
_property_input_html: function(id, value, options) {
var text_field;
if (options == null) {
options = {};
}
text_field = "<input type='text' id='hallo_img_" + id + "' value='" + value + "'>";
return this._property_html(text_field, options);
},
_property_cb_html: function(id, checked, options) {
var cb, checked_attr;
if (options == null) {
options = {};
}
checked_attr = checked ? 'checked=checked' : '';
cb = "<input type='checkbox' id='hallo_img_" + id + "' " + checked_attr + "'>";
return this._property_html(cb, options);
}
});
})(jQuery);
}).call(this);

View File

@ -507,9 +507,9 @@ module.exports = [
{
filter: 'img',
replacement: function(content, node) {
var alt = node.alt || '';
var alt = node.getAttribute("alt") || '';
var src = node.getAttribute('src') || '';
var title = node.title || '';
var title = node.getAttribute('title') || '';
var titlePart = title ? ' "'+ title +'"' : '';
return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : '';
}

View File

@ -31,7 +31,7 @@ function onCircleChanged()
{ $('#fncirc').addClass("dirty"); }
function removeCircle() {
Yavsc.message(false);
Yavsc.notice(false);
var id = $(this).attr('cid');
$.ajax({
url: CirclesApiUrl+"/Delete/"+id,
@ -44,12 +44,12 @@ function removeCircle() {
400: onAjaxBadInput,
error: function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
Yavsc.message(xhr.status+" : "+xhr.responseText);
else Yavsc.message(false);
Yavsc.notice(xhr.status+" : "+xhr.responseText);
else Yavsc.notice(false);
}}});
}
function modifyCircle() {
Yavsc.message(false);
Yavsc.notice(false);
var id = $('#id').val();
var circle = { title: $("#title").val(), id: id} ;
$.ajax({
@ -69,7 +69,7 @@ function removeCircle() {
function addCircle()
{
Yavsc.message(false);
Yavsc.notice(false);
var circle = { title: $("#title").val() } ;
$("#title").text('');
$.ajax({

View File

@ -17,12 +17,16 @@ self.showHide = function () {
$(this).html(this.oldhtml);
}
};
self.message = function (msg) {
if (msg) {
$("#message").removeClass("hidden");
$("#message").text(msg);
} else { $("#message").addClass("hidden"); } };
self.dimiss = function () {
$(this).parent().remove();
}
self.notice = function (msg, msgok) {
if (!msgok) msgok='Ok';
if (msg) {
var note = $('<div class="notification">'+msg+'<br></div>');
$('<a class="actionlink"><i class="fa fa-check">'+msgok+'</i></a>').click(self.dimiss).appendTo(note);
note.appendTo("#notifications");
} };
self.onAjaxBadInput = function (data)
@ -39,10 +43,9 @@ self.message = function (msg) {
}
self.onAjaxError = function (xhr, ajaxOptions, thrownError) {
if (xhr.status!=400)
Yavsc.message(xhr.status+" : "+xhr.responseText);
else Yavsc.message(false);
Yavsc.notice(xhr.status+" : "+xhr.responseText);
else Yavsc.notice(false);
}
return self;
})();

View File

@ -11,45 +11,43 @@
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<div>
<% using(Html.BeginForm("ValidateEdit","Blogs")) { %>
<fieldset>
<legend>Billet</legend>
<%= Html.LabelFor(model => model.Title) %> <%= Html.ValidationMessage("Title") %> : <br>
<input name="Title" id="Title" class="fullwidth">
<br>
<%= Html.LabelFor(model => model.Content) %>
<%= Html.ValidationMessage("Content") %>: <br>
<style> #Content { }
</style>
<textarea id="Content" name="Content" class="fullwidth" ><%=Html.Markdown(Model.Content)%></textarea><br>
<%= Html.CheckBox( "Visible" ) %>
<%= Html.LabelFor(model => model.Visible) %>
<%= Html.ValidationMessage("Visible", "*") %>
<br/>
<%= Html.LabelFor(model => model.AllowedCircles) %>
<%= Html.ListBox("AllowedCircles") %>
<%= Html.ValidationMessage("AllowedCircles", "*") %>
<%=Html.Hidden("Author")%>
<%=Html.Hidden("Id")%>
<input type="submit">
</fieldset>
<% } %>
</div>
<div class="post">
<h1><div id="vtitle" for="Title" class="post title editable"><%=Html.Markdown(Model.Title)%></div></h1>
<div id="vcontent" for="Content" class="post content editable">
<span class="placard editable" for="Photo">
<img src="<%=Model.Photo%>" alt="photo" id="vphoto" >
</span>
<!-- TODO? Model.Photo.(Legend|Date|Location|ref) -->
<h1 id="vtitle" for="Title" class="editable"><%=Html.Markdown(Model.Title)%></h1>
<div id="vcontent" for="Content" class="editable">
<%=Html.Markdown(Model.Content,"/bfiles/"+Model.Id+"/")%>
</div>
</div>
<span id="viewsource" class="actionlink">
<i class="fa fa-code">View Source</i></span>
<span id="hidesource" class="actionlink hidden">
<i class="fa fa-code">Hide Source</i>
</span>
<script>
function dumpprops(obj) {
var str = "";
for(var k in obj)
if (obj.hasOwnProperty(k))
str += k + " = " + obj[k] + "\n";
return (str); }
$(document).ready(function(){
$('#hidesource').click(function(){
$('#source').addClass('hidden');
$('#viewsource').removeClass('hidden');
$('#hidesource').addClass('hidden');
});
$('#viewsource').click(function(){
$('#source').removeClass('hidden');
$('#viewsource').addClass('hidden');
$('#hidesource').removeClass('hidden');
});
jQuery('.placard').hallo({plugins: {'hallo-image-insert-edit': { lang: 'fr' } } });
jQuery('#vtitle').hallo({
plugins: {
'halloformat': {},
@ -67,12 +65,6 @@ jQuery('#vcontent').hallo({
'hallo-image-insert-edit': {
lang: 'fr'
},
'halloimage': {
searchUrl: apiBaseUrl+'/Blogs/SearchFile/'+$('#Id').val(),
uploadUrl: apiBaseUrl+'/Blogs/PostFile/'+$('#Id').val(),
suggestions: true,
insert_file_dialog_ui_url: '<%= Url.Content("~/Blog/ChooseMedia/?id="+Model.Id) %>'
},
'halloreundo': {},
'hallocleanhtml': {
format: false,
@ -82,7 +74,6 @@ jQuery('#vcontent').hallo({
'em',
'strong',
'br',
'div',
'ol',
'ul',
'li',
@ -132,10 +123,19 @@ var updateHtml = function(id,content) {
jView.html(html);
};
jQuery('.placard').bind('hallomodified', function(event, data) {
// TODO get image source from data.content
$('#'+this.attributes["for"].value).val(
$('#vphoto').attr('src'));
});
// Update Markdown every time content is modified
jQuery('.editable').bind('hallomodified', function(event, data) {
var onMDModified = ( function (event, data) {
showSource(this.attributes["for"].value, data.content);
});
jQuery('#vtitle').bind('hallomodified', onMDModified);
jQuery('#vcontent').bind('hallomodified', onMDModified);
jQuery('#Content').bind('keyup', function() {
updateHtml(this.id, this.value);
});
@ -145,7 +145,7 @@ var updateHtml = function(id,content) {
showSource("Title",jQuery('#vtitle').html());
showSource("Content",jQuery('#vcontent').html());
});
</script>
@ -153,8 +153,8 @@ var updateHtml = function(id,content) {
function submitFilesTo(method)
{
var data = new FormData($('#uploads').get()[0]);
Yavsc.message('Submitting via '+method);
var data = new FormData($('#frmajax').get()[0]);
Yavsc.notice('Submitting via '+method);
$.ajax({
url: apiBaseUrl+'/Blogs/'+method+'/'+$('#Id').val(),
type: "POST",
@ -163,7 +163,7 @@ function submitFilesTo(method)
contentType: false,
success: function(data) {
$('#Content').val(data+"\n"+$('#Content').val());
Yavsc.message(false);
Yavsc.notice(false);
},
error: Yavsc.onAjaxError,
});
@ -174,8 +174,27 @@ function submitImport()
function submitFile()
{ submitFilesTo('PostFile'); }
function submitBaseDoc()
{
var data = new FormData($('#frmajax').get()[0]);
Yavsc.notice('Submitting via '+method);
$.ajax({
url: apiBaseUrl+'/Blogs/'+method+'/'+$('#Id').val(),
type: "POST",
data: data,
processData: false,
contentType: false,
success: function(data) {
$('#Content').val(data+"\n"+$('#Content').val());
Yavsc.notice('Posted updated');
},
error: Yavsc.onAjaxError,
});
}
</script>
<form id="uploads" method="post" enctype="multipart/form-data">
<form id="frmajax">
<fieldset>
<legend>Fichiers attachés</legend>
<input type="file" name="attached" id="postedfile" multiple>
@ -183,6 +202,31 @@ function submitFile()
<input type="button" value="importer les documents" onclick="submitImport()">
</fieldset>
</form>
<% using(Html.BeginForm("ValidateEdit","Blogs")) { %>
<fieldset>
<legend>Contrôle d'accès au Billet</legend>
<%= Html.LabelFor(model => model.Visible) %> : <%= Html.CheckBox( "Visible" ) %>
<i id="note_visible">Note: Si un ou plusieurs cercles sont séléctionnés ici,
le billet ne sera visible qu'aux membres de ces cercles.</i>
<%= Html.ValidationMessage("Visible", "*") %>
<%= Html.LabelFor(model => model.AllowedCircles) %>
<%= Html.ListBox("AllowedCircles") %>
<%= Html.ValidationMessage("AllowedCircles", "*") %>
</fieldset>
<fieldset id="source" class="hidden">
<%=Html.Hidden("Author")%>
<%=Html.Hidden("Id")%>
<%= Html.LabelFor(model => model.Photo) %>
<%=Html.TextBox("Photo")%>
<%=Html.ValidationMessage("Photo")%><br>
<%= Html.LabelFor(model => model.Title) %>
<%=Html.TextBox("Title")%>
<%=Html.ValidationMessage("Title")%><br>
<%=Html.TextArea("Content")%>
<%=Html.ValidationMessage("Content")%>
</fieldset>
<i class="af af-check actionlink"><input type="submit" id="validate" value="Valider"></i>
<% } %>
<aside>
Id:<%= Html.ActionLink( Model.Id.ToString() , "UserPost", new { user= Model.Author, title=Model.Title, id = Model.Id }, new { @class = "usertitleref actionlink" }) %>

View File

@ -4,7 +4,7 @@
</asp:Content>
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="header1" runat="server">
<h1 class="blogtitle"><% if (ViewData["Avatar"]!=null) { %>
<img src="<%=ViewData["Avatar"]%>" alt="" id="logo"/>
<img src="<%=ViewData["Avatar"]%>" alt="avatar" id="avatar"/>
<% } %>
<%= Html.ActionLink(Model.Title,"UserPost", new{user=Model.Author, title = Model.Title}, null) %>
<span> - <%= Html.ActionLink((string)ViewData ["BlogTitle"] ,"UserPosts",new{user=Model.Author}, null) %>
@ -18,6 +18,11 @@
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<% foreach (var be in Model) { %>
<div class="post">
<% if (be.Photo != null) { %>
<img src="<%=Url.Content(be.Photo)%>" alt="<%=be.Title%>">
<% } %>
<%= Html.Markdown(be.Content,"/bfiles/"+be.Id+"/") %>
<% string username = Membership.GetUser()==null ? null : Membership.GetUser().UserName; %>
@ -32,12 +37,12 @@
<% if (Membership.GetUser()!=null) {
if (Membership.GetUser().UserName==be.Author)
{ %> <div class="metapost">
{ %> <div class="control">
<%= Html.ActionLink("Editer","Edit", new { id = be.Id }, new { @class="actionlink" }) %>
<%= Html.ActionLink("Supprimer","RemovePost", new { id = be.Id }, new { @class="actionlink" } ) %>
</div> <% } %>
<aside>
<aside class="control">
<% using (Html.BeginForm("Comment","Blogs")) { %>
<%=Html.Hidden("Author")%>
<%=Html.Hidden("Title")%>

View File

@ -42,7 +42,6 @@
<form runat="server" id="form1" method="GET">
<%
rp1.ResultCount = (int) ViewData["RecordCount"];
rp1.CurrentPage = (int) ViewData["PageIndex"];
rp1.PageIndex = (int) ViewData["PageIndex"];
%>
<yavsc:ResultPages id="rp1" Action = "?pageIndex={0}" runat="server">

View File

@ -259,8 +259,8 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add key="SmtpServer" value="smtp.free.fr" />
<add key="AdminEMail" value="paulschneider@free.fr" />
<add key="OwnerEMail" value="" />
<add key="Name" value="Totem production" />
<add key="DefaultController" value="Blogs" />
<add key="Name" value="TOTEM PRODUCTION" />
<add key="DefaultController" value="Home" />
<add key="DefaultAvatar" value="/images/noavatar.png;image/png" />
<add key="RegistrationMessage" value="/RegistrationMail.txt" />
<!-- <add key="ClientValidationEnabled" value="true" /> -->

View File

@ -171,6 +171,7 @@ CREATE TABLE blog
bcontent text NOT NULL,
visible boolean NOT NULL,
_id bigserial NOT NULL,
photo character varying(512),
CONSTRAINT blog_pkey PRIMARY KEY (_id),
CONSTRAINT bloguser FOREIGN KEY (applicationname, username)
REFERENCES users (applicationname, username) MATCH SIMPLE
@ -180,6 +181,8 @@ WITH (
OIDS=FALSE
);
COMMENT ON COLUMN blog.photo IS 'a photo url, supposed to be the main photo
related to this post';
CREATE TABLE blfiles
(

View File

@ -28,6 +28,15 @@ namespace Yavsc.Model.Blogs
}
}
/// <summary>
/// Gets or sets the photo.
/// </summary>
/// <value>The photo.</value>
public string Photo {
get;
set;
}
string title;
/// <summary>

View File

@ -100,6 +100,10 @@ namespace Yavsc.Model.Blogs
Provider.UpdatePost (postid, title, content, visible, cids);
}
public static void UpdatePostPhoto (long postid, string photo)
{
Provider.UpdatePostPhoto (postid, photo);
}
/// <summary>
/// Finds the post.

View File

@ -150,6 +150,13 @@ namespace Yavsc.Model.Blogs
/// </summary>
/// <param name="tagid">Tagid.</param>
public abstract void RemoveTag (long tagid);
/// <summary>
/// Updates the post photo.
/// </summary>
/// <param name="pid">Pid.</param>
/// <param name="photo">Photo.</param>
public abstract void UpdatePostPhoto (long pid, string photo);
}
}

View File

@ -1,3 +1,18 @@
2015-10-08 Paul Schneider <paul@pschneider.fr>
* BlogEntry.cs: defines the photo in the model
* BlogManager.cs: a new method to set the photo on a blog
post.
* BlogProvider.cs: the blog provider now also gives some photo
* LocalizedText.fr.Designer.cs: Reordering the french
localisation resource
* LocalizedText.fr.resx: Reorders the french localisation
resource
2015-10-04 Paul Schneider <paul@pschneider.fr>
* MarkdownHelper.cs:

View File

@ -76,9 +76,9 @@ namespace Yavsc.Model {
}
}
public static string was_added_to_the_role {
public static string Create {
get {
return ResourceManager.GetString("was_added_to_the_role", resourceCulture);
return ResourceManager.GetString("Create", resourceCulture);
}
}
@ -88,12 +88,6 @@ namespace Yavsc.Model {
}
}
public static string ImportException {
get {
return ResourceManager.GetString("ImportException", resourceCulture);
}
}
public static string Title {
get {
return ResourceManager.GetString("Title", resourceCulture);
@ -124,12 +118,6 @@ namespace Yavsc.Model {
}
}
public static string DocTemplateException {
get {
return ResourceManager.GetString("DocTemplateException", resourceCulture);
}
}
public static string Ciffer {
get {
return ResourceManager.GetString("Ciffer", resourceCulture);
@ -172,9 +160,9 @@ namespace Yavsc.Model {
}
}
public static string User_name {
public static string ImportException {
get {
return ResourceManager.GetString("User_name", resourceCulture);
return ResourceManager.GetString("ImportException", resourceCulture);
}
}
@ -196,9 +184,9 @@ namespace Yavsc.Model {
}
}
public static string Welcome {
public static string was_added_to_the_role {
get {
return ResourceManager.GetString("Welcome", resourceCulture);
return ResourceManager.GetString("was_added_to_the_role", resourceCulture);
}
}
@ -220,15 +208,21 @@ namespace Yavsc.Model {
}
}
public static string UserName {
public static string Consultant {
get {
return ResourceManager.GetString("UserName", resourceCulture);
return ResourceManager.GetString("Consultant", resourceCulture);
}
}
public static string Remember_me {
public static string EventWebPage {
get {
return ResourceManager.GetString("Remember_me", resourceCulture);
return ResourceManager.GetString("EventWebPage", resourceCulture);
}
}
public static string User_List {
get {
return ResourceManager.GetString("User List", resourceCulture);
}
}
@ -238,15 +232,21 @@ namespace Yavsc.Model {
}
}
public static string Home {
public static string Not_Approuved {
get {
return ResourceManager.GetString("Home", resourceCulture);
return ResourceManager.GetString("Not Approuved", resourceCulture);
}
}
public static string Pdf_version {
public static string Remember_me {
get {
return ResourceManager.GetString("Pdf_version", resourceCulture);
return ResourceManager.GetString("Remember_me", resourceCulture);
}
}
public static string DocTemplateException {
get {
return ResourceManager.GetString("DocTemplateException", resourceCulture);
}
}
@ -292,21 +292,21 @@ namespace Yavsc.Model {
}
}
public static string Welcome {
get {
return ResourceManager.GetString("Welcome", resourceCulture);
}
}
public static string Online {
get {
return ResourceManager.GetString("Online", resourceCulture);
}
}
public static string Not_Approuved {
public static string Home {
get {
return ResourceManager.GetString("Not Approuved", resourceCulture);
}
}
public static string Create {
get {
return ResourceManager.GetString("Create", resourceCulture);
return ResourceManager.GetString("Home", resourceCulture);
}
}
@ -328,27 +328,9 @@ namespace Yavsc.Model {
}
}
public static string role_created {
public static string User_name {
get {
return ResourceManager.GetString("role_created", resourceCulture);
}
}
public static string User_List {
get {
return ResourceManager.GetString("User List", resourceCulture);
}
}
public static string EventWebPage {
get {
return ResourceManager.GetString("EventWebPage", resourceCulture);
}
}
public static string Item_added_to_basket {
get {
return ResourceManager.GetString("Item_added_to_basket", resourceCulture);
return ResourceManager.GetString("User_name", resourceCulture);
}
}
@ -358,9 +340,21 @@ namespace Yavsc.Model {
}
}
public static string Consultant {
public static string Pdf_version {
get {
return ResourceManager.GetString("Consultant", resourceCulture);
return ResourceManager.GetString("Pdf_version", resourceCulture);
}
}
public static string Item_added_to_basket {
get {
return ResourceManager.GetString("Item_added_to_basket", resourceCulture);
}
}
public static string role_created {
get {
return ResourceManager.GetString("role_created", resourceCulture);
}
}

View File

@ -12,62 +12,60 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="access_denied"><value>Accès refusé</value></data>
<data name="Bill_edition"><value>Édition d'un billet</value></data>
<data name="Consultant"><value>Consultant</value></data>
<data name="Count"><value>Nombre</value></data>
<data name="Ciffer"><value>Chiffre</value></data>
<data name="ImportException"><value>Exception à l'import</value></data>
<data name="none"><value>aucun(e)</value></data>
<data name="Modify"><value>Modifier</value></data>
<data name="no_content"><value>pas de contenu</value></data>
<data name="Title"><value>Titre</value></data>
<data name="Description"><value>Description</value></data>
<data name="Product_reference"><value>Référence produit</value></data>
<data name="Unitary_cost"><value>Coût unitaire</value></data>
<data name="Count"><value>Nombre</value></data>
<data name="Preview"><value>Prévisualiser</value><comment>Prévisualiser le document</comment></data>
<data name="Welcome"><value>Bienvenue</value><comment></comment></data>
<data name="User List"><value>Liste des utilisateurs</value><comment></comment></data>
<data name="Register"><value>Enregistez-vous</value></data>
<data name="Online"><value>En ligne</value></data>
<data name="Offline"><value>Hors ligne</value></data>
<data name="Not Approuved"><value>Non approuvé</value></data>
<data name="Remove"><value>Supprimer</value></data>
<data name="Pdf_version"><value>Version Pdf</value></data>
<data name="Tex_version"><value>Version LaTeX</value></data>
<data name="User_name"><value>Nom d'utilisateur</value></data>
<data name="Google_error"><value>Erreur Google : {0}</value></data>
<data name="access_denied"><value>Accès refusé</value></data>
<data name="UserName"><value>Nom d'utilisateur</value></data>
<data name="Google_calendar"><value>Agenda Google</value></data>
<data name="Consultant"><value>Consultant</value></data>
<data name="MinDate"><value>Date minimale du rendez-vous</value></data>
<data name="MaxDate"><value>Date maximale du rendez-vous</value></data>
<data name="Date_search"><value>Demande de rendez-vous</value></data>
<data name="Remember_me"><value>Se souvenir du mot de passe</value></data>
<data name="DocTemplateException"><value>Une erreur est survenue à la génération de votre document</value></data>
<data name="Message_sent"><value>Votre message a été envoyé</value></data>
<data name="was_added_to_the_role"><value>a été ajouté au rôle</value></data>
<data name="was_added_to_the_empty_role"><value>Il n'y avait pas 'utilisateur dans le rôle '{1}'. Vous ({0}) avez été ajouté au rôle '{1}'.</value></data>
<data name="younotadmin"><value>Vous n'êtes pas administrateur</value></data>
<data name="role_created"><value>Rôle créé</value></data>
<data name="Item_added_to_basket"><value>Article ajouté au panier</value></data>
<data name="Estimate_not_found"><value>Devis non trouvé</value></data>
<data name="My_Estimates"><value>Mes estimations</value></data>
<data name="User_name"><value>Nom d'utilisateur</value></data>
<data name="Circles"><value>Cercles</value></data>
<data name="Location"><value>Lieu</value></data>
<data name="StartDate"><value>Date de démarrage</value></data>
<data name="EndDate"><value>Date de fin</value></data>
<data name="ProviderName"><value>Nom du fournisseur</value></data>
<data name="ProviderId"><value>Identifiant du fournisseur</value></data>
<data name="Comment"><value>Commentaire</value></data>
<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="Create"><value>Créer</value></data>
<data name="Members"><value>Membres</value></data>
<data name="UserName"><value>Nom d'utilisateur</value></data>
<data name="Date_search"><value>Demande de rendez-vous</value></data>
<data name="DocTemplateException"><value>Une erreur est survenue à la génération de votre document</value></data>
<data name="Description"><value>Description</value></data>
<data name="DisplayName"><value>Nom affiché</value></data>
<data name="entries"><value>entrées</value></data>
<data name="EndDate"><value>Date de fin</value></data>
<data name="Estimate_not_found"><value>Devis non trouvé</value></data>
<data name="EventWebPage"><value>Page web de l'événement</value></data>
<data name="Google_calendar"><value>Agenda Google</value></data>
<data name="Google_error"><value>Erreur Google : {0}</value></data>
<data name="Home"><value>Accueil</value></data>
<data name="ImgLocator"><value>URI de l'image</value></data>
<data name="ImportException"><value>Exception à l'import</value></data>
<data name="InternalServerError"><value>Erreur serveur interne</value></data>
<data name="Item_added_to_basket"><value>Article ajouté au panier</value></data>
<data name="Location"><value>Lieu</value></data>
<data name="MaxDate"><value>Date maximale du rendez-vous</value></data>
<data name="Members"><value>Membres</value></data>
<data name="Message_sent"><value>Votre message a été envoyé</value></data>
<data name="MinDate"><value>Date minimale du rendez-vous</value></data>
<data name="Modify"><value>Modifier</value></data>
<data name="My_Estimates"><value>Mes estimations</value></data>
<data name="none"><value>aucun(e)</value></data>
<data name="Not Approuved"><value>Non approuvé</value></data>
<data name="no_content"><value>pas de contenu</value></data>
<data name="Offline"><value>Hors ligne</value></data>
<data name="Online"><value>En ligne</value></data>
<data name="Pdf_version"><value>Version Pdf</value></data>
<data name="Preview"><value>Prévisualiser</value><comment>Prévisualiser le document</comment></data>
<data name="Product_reference"><value>Référence produit</value></data>
<data name="ProviderId"><value>Identifiant du fournisseur</value></data>
<data name="ProviderName"><value>Nom du fournisseur</value></data>
<data name="Register"><value>Enregistez-vous</value></data>
<data name="Remember_me"><value>Se souvenir du mot de passe</value></data>
<data name="Remove"><value>Supprimer</value></data>
<data name="role_created"><value>Rôle créé</value></data>
<data name="StartDate"><value>Date de démarrage</value></data>
<data name="Tex_version"><value>Version LaTeX</value></data>
<data name="Title"><value>Titre</value></data>
<data name="Unitary_cost"><value>Coût unitaire</value></data>
<data name="User List"><value>Liste des utilisateurs</value><comment></comment></data>
<data name="User_name"><value>Nom d'utilisateur</value></data>
<data name="was_added_to_the_role"><value>a été ajouté au rôle</value></data>
<data name="was_added_to_the_empty_role"><value>Il n'y avait pas 'utilisateur dans le rôle '{1}'. Vous ({0}) avez été ajouté au rôle '{1}'.</value></data>
<data name="Welcome"><value>Bienvenue</value><comment></comment></data>
<data name="younotadmin"><value>Vous n'êtes pas administrateur</value></data>
</root>