* Adds client resourses for Markdown.js

* Implements a part of the client UI at editing Circle collections
vnext
Paul Schneider 9 years ago
parent 17f57d5542
commit 9748c9d7e4
19 changed files with 552 additions and 119 deletions

13
.gitignore vendored

@ -0,0 +1,13 @@
*/bin
*/obj
plugins/*/bin
plugins/*/obj
*.userprefs
packages
web/avatars
web/users
web/Web References
build
.nuget
.gitignore

@ -36,6 +36,28 @@ namespace WorkFlowProvider
/// </summary>
public class NpgsqlCircleProvider : CircleProvider
{
#region implemented abstract members of CircleProvider
public override void RemoveMembership (long circle_id, string member)
{
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "delete from circle_members where circle_id = :cid and username = :uname";
cmd.Parameters.AddWithValue("cid",circle_id);
cmd.Parameters.AddWithValue("uname",member);
cnx.Open ();
cmd.ExecuteNonQuery ();
cnx.Close ();
}
}
public override void RemoveMember (string member)
{
throw new NotImplementedException ();
}
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="WorkFlowProvider.NpgsqlCircleProvider"/> class.
/// </summary>
@ -88,23 +110,6 @@ namespace WorkFlowProvider
}
}
/// <summary>
/// Remove the specified user.
/// </summary>
/// <param name="id">circle Identifier.</param>
/// <param name="username">User name.</param>
public override void Remove (long id, string username)
{
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "delete from circle_members where circle_id = :cid and username = :uname";
cmd.Parameters.AddWithValue("cid",id);
cmd.Parameters.AddWithValue("uname",username);
cnx.Open ();
cmd.ExecuteNonQuery ();
cnx.Close ();
}
}
/// <summary>
/// Get the specified id.

@ -44,7 +44,7 @@ namespace Yavsc.ApiControllers
public class AuthorizationDenied : HttpRequestException {
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.ApiControllers.FrontOfficeController+AuthorizationDenied"/> class.
/// Initializes a new instance of the Yavsc.ApiControllers.AuthorizationDenied class.
/// </summary>
/// <param name="msg">Message.</param>
public AuthorizationDenied(string msg) : base(msg)

@ -29,26 +29,6 @@ using Yavsc.Model;
namespace Yavsc.ApiControllers
{
/// <summary>
/// New circle.
/// </summary>
public class NewCircle {
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
public string title { get ; set; }
/// <summary>
/// Gets or sets the users.
/// </summary>
/// <value>The users.</value>
public string [] users { get ; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Yavsc.ApiControllers.NewCircle"/> is private.
/// </summary>
/// <value><c>true</c> if is private; otherwise, <c>false</c>.</value>
public bool isPrivate { get; set; }
}
/// <summary>
/// Circle controller.
@ -62,10 +42,10 @@ namespace Yavsc.ApiControllers
/// <param name="model">Model.</param>
[Authorize,
AcceptVerbs ("POST")]
public long Create(NewCircle model)
public long Create(Circle model)
{
string user = Membership.GetUser ().UserName;
return CircleManager.DefaultProvider.Create (user, model.title, model.users);
return CircleManager.DefaultProvider.Create (user, model.Title, model.Members);
}
/// <summary>
@ -94,6 +74,20 @@ namespace Yavsc.ApiControllers
CircleManager.DefaultProvider.Delete (id);
}
/// <summary>
/// Removes the user from circle.
/// </summary>
/// <param name="id">Identifier.</param>
/// <param name="username">Username.</param>
[Authorize,
AcceptVerbs ("GET")]
public void RemoveUserFromCircle(long id, string username)
{
checkIsOwner (CircleManager.DefaultProvider.Get(id));
CircleManager.DefaultProvider.RemoveMembership (id,username);
}
private void checkIsOwner(Circle c)
{
string user = Membership.GetUser ().UserName;

@ -121,6 +121,9 @@ label {
font-size: large;
background-color: rgba(0,64,0,0.1);
}
.dirty {
background-color: rgba(128,128,0,0.3);
}
.error {
color: #f88;
font-size: large;

@ -214,12 +214,13 @@ namespace Yavsc.Controllers
return View (model);
}
/// <summary>
/// Profile the specified user.
/// </summary>
/// <param name="user">User name.</param>
[Authorize]
[HttpGet]
/// <summary>
/// Profile the specified id.
/// </summary>
/// <param name="id">Identifier.</param>
public ActionResult Profile (string id)
{
if (id == null)
@ -230,14 +231,16 @@ namespace Yavsc.Controllers
return View (model);
}
[Authorize]
[HttpPost]
/// <summary>
/// Profile the specified user, model and AvatarFile.
/// Profile the specified id, model and AvatarFile.
/// </summary>
/// <param name="user">User.</param>
/// <param name="id">Identifier.</param>
/// <param name="model">Model.</param>
/// <param name="AvatarFile">Avatar file.</param>
[Authorize]
[HttpPost]
public ActionResult Profile (string id, Profile model, HttpPostedFileBase AvatarFile)
{
// ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash"

@ -0,0 +1,16 @@
MarkdownDeep License
====================
MarkdownDeep - <http://www.toptensoftware.com/markdowndeep>
Copyright (C) 2010-2011 Topten Software
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this product except in
compliance with the License. You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

@ -0,0 +1,60 @@
MarkdownDeep Quick Reference
============================
Setting up the Client Side Editor
---------------------------------
The following assumes you've installed the full edition MarkdownDeep using NuGet and explains how to setup
a client side editor with toolbar, resize bar, real-time preview and syntax reference help.
1. In either your master view page, or in the view containing the editor ensure the following references are in place:
<link rel="stylesheet" type="text/css" href="/Scripts/mdd_styles.css" />
<script type="text/javascript" src="/Scripts/jQuery-1.4.1.min.js"></script>
<script type="text/javascript" src="/Scripts/MarkdownDeepLib.min.js"></script>
2. Insert the following markup at the location you want the editor to appear:
<div class="mdd_toolbar"></div>
<%=Html.TextArea("content", new { @class="mdd_editor" }) %>
<div class="mdd_resizer"></div>
<div class="mdd_preview"></div>
Note, the mdd_toolbar, mdd_resizer and mdd_preview divs are all optional. If ommitted, the jQuery plugin will
create them however this may cause the page to appear to "jump" as it loads. By using the above divs and the
associated mdd_styles.css stylesheet, the correct sizing can be in-place immediately, eliminating these jumps.
3. Use the jQuery plugin to convert the textarea into a Markdown editor. For more options, see below.
$(function () {
$("textarea.mdd_editor").MarkdownDeep({
help_location:"/Scripts/mdd_help.htm",
ExtraMode: true
});
})
See <http://www.toptensoftware.com/markdowndeep/editor> for more information on configuring the editor.
Server Side Translation
-----------------------
The above steps allow you to create forms where the user can enter and preview Markdown content. This section
explains how to perform the equivalent translation of the entered content server side.
1. When you installed MarkdownDeep to your project with NuGet, a reference to MarkdownDeep.dll would already have
been created.
2. To translate Markdown, instantiate an instance of the MarkdownDeep class and call it's Translate method to
do the translation:
// Instantiate
var md=new MarkdownDeep.Markdown();
// Set options
md.ExtraMode=true;
// Translate
var html=md.Transform(plaintext);
See <http://www.toptensoftware.com/markdowndeep/api> for other methods and properties.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

@ -0,0 +1,166 @@
<h2>Markdown Formatting</h2>
<p><a href="http://daringfireball.net/projects/markdown/" target="_blank">Markdown</a> turns plain text formatting into fancy HTML formatting.</p>
<h3>Phrase Emphasis</h3>
<pre><code>*italic* **bold**
_italic_ __bold__
</code></pre>
<h3>Links</h3>
<p>Inline:</p>
<pre><code>An [example](http://url.com/ &quot;Title&quot;)
</code></pre>
<p>Reference-style labels (titles are optional):</p>
<pre><code>An [example][id]. Then, anywhere
else in the doc, define the link:
[id]: http://example.com/ &quot;Title&quot;
</code></pre>
<h3>Images</h3>
<p>Inline (titles are optional):</p>
<pre><code>![alt text](/path/img.jpg &quot;Title&quot;)
</code></pre>
<p>Reference-style:</p>
<pre><code>![alt text][id]
[id]: /url/to/img.jpg &quot;Title&quot;
</code></pre>
<h3>Headers</h3>
<p>Setext-style:</p>
<pre><code>Header 1
========
Header 2
--------
</code></pre>
<p>atx-style (closing #'s are optional):</p>
<pre><code># Header 1 #
## Header 2 ##
###### Header 6
</code></pre>
<h3>Lists</h3>
<p>Ordered, without paragraphs:</p>
<pre><code>1. Foo
2. Bar
</code></pre>
<p>Unordered, with paragraphs:</p>
<pre><code>* A list item.
With multiple paragraphs.
* Bar
</code></pre>
<p>You can nest them:</p>
<pre><code>* Abacus
* answer
* Bubbles
1. bunk
2. bupkis
* BELITTLER
3. burper
* Cunning
</code></pre>
<h3>Blockquotes</h3>
<pre><code>&gt; Email-style angle brackets
&gt; are used for blockquotes.
&gt; &gt; And, they can be nested.
&gt; #### Headers in blockquotes
&gt;
&gt; * You can quote a list.
&gt; * Etc.
</code></pre>
<h3>Code Spans</h3>
<pre><code>`&lt;code&gt;` spans are delimited
by backticks.
You can include literal backticks
like `` `this` ``.
</code></pre>
<h3>Preformatted Code Blocks</h3>
<p>Indent every line of a code block by at least 4 spaces or 1 tab.</p>
<pre><code>This is a normal paragraph.
This is a preformatted
code block.
</code></pre>
<h3>Horizontal Rules</h3>
<p>Three or more dashes or asterisks:</p>
<pre><code>---
* * *
- - - -
</code></pre>
<h3>Manual Line Breaks</h3>
<p>End a line with two or more spaces:</p>
<pre><code>Roses are red,
Violets are blue.
</code></pre>
<h2>Extra Mode</h2>
These formatting features are only available when Extra Mode is enabled.
<h3>Markdown In Html</h3>
<p>Enable markdown in HTML block level elements:</p>
<pre><code>&lt;div markdown=&quot;1&quot;&gt;
Markdown **still** works.
&lt;/div&gt;
</code></pre>
<h3>Fenced Code Blocks</h3>
<p>Code blocks delimited by 3 or more tildas:</p>
<pre><code>~~~
This is a preformatted
code block
~~~
</code></pre>
<h3>Header IDs</h3>
<p>Set the id of headings with <code>{#&lt;id&gt;}</code> at end of heading line:</p>
<pre><code>## My Heading {#myheading}
</code></pre>
<h3>Tables</h3>
<pre><code>Fruit |Color
---------|----------
Apples |Red
Pears |Green
Bananas |Yellow</code></pre>
<h3>Definition Lists</h3>
<pre><code>Term 1
: Definition 1
Term 2
: Definition 2</code></pre>
<h3>Footnotes</h3>
<pre><code>Body text with a footnote [^1]
[^1]: Footnote text here
</code></pre>
<h3>Abbreviations</h3>
<pre><code>MDD &lt;- will have title
*[MDD]: MarkdownDeep
</code></pre>
<p>&nbsp;</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

@ -0,0 +1,211 @@
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(mdd_modal_background.png);
}
div.mdd_modal_frame
{
width:650px;
height:400px;
background-color:White;
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;
background-color:#808080;
z-index:1999;
border-radius:4px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
line-height:1em;
}
div.mdd_modal_button a
{
color:White;
text-decoration:none;
}
div.mdd_modal_button a:hover
{
color:Orange;
}
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(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;
background-color:#f8f8f8;
}
div.mdd_toolbar_wrap
{
width:100%;
}
div.mdd_toolbar
{
padding:5px;
height:20px;
}
div.mdd_toolbar ul
{
margin:0;
padding:0;
}
div.mdd_toolbar li
{
float:left;
margin:0;
padding:0;
list-style:none;
}
div.mdd_toolbar a.mdd_button
{
background-image:url(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;
color:#404040;
font-size:smaller;
}
div.mdd_links a:hover
{
color:black;
}
div.mdd_editor_wrap
{
padding-right: 8px;
}
textarea.mdd_editor
{
width:100%;
resize:none;
margin:0;padding: 3px;
}
div.mdd_resizer_wrap
{
width:100%;
}
div.mdd_resizer
{
background:#f8f8f8;
background-image:url("mdd_gripper.png");
background-position:center center;
background-repeat:no-repeat;
padding-left:2px;
padding-right:2px;
height:9px;
border:solid 1px #d0d0d0;
margin-top:-1px;
cursor:n-resize;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

@ -43,7 +43,7 @@ $("#tbc").stupidtable();
<legend id="lgdnvcirc"></legend>
<span id="msg" class="field-validation-valid error"></span>
<label for="title"><b><%=Html.Translate("Title")%></b></label>
<input type="text" id="title" name="title" class="inputtext"/>
<input type="text" id="title" name="title" class="inputtext" onchange="onTitleChanged"/>
<span id="Err_cr_title" class="field-validation-valid error"></span>
<table id="tbmbrs">
<thead>
@ -91,19 +91,24 @@ function(json) { $("#title").val( json.Title); $("#users").val( json.Members ) ;
function editNewCircle() {
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
$('#lgdnvcirc').html("Creation d'un cercle");
$('#btnnewcircle').val("Créer");
$('#fncirc').removeClass("dirty");
}
function selectCircle() {
if ($('#fncirc').hasClass('hidden')) $('#fncirc').removeClass('hidden')
var id = $(this).attr('cid');
$('#lgdnvcirc').html("Edition du cercle");
$('#btnnewcircle').val("Modifier");
// get it from the server
getCircle(id);
$('#fncirc').removeClass("dirty");
}
function onmembersChange(newval)
{
}
{$('#fncirc').addClass("dirty");}
function onTitleChanged()
{ $('#fncirc').addClass("dirty"); }
function removeCircle() {
message(false);
@ -137,7 +142,7 @@ function selectCircle() {
function addCircle()
{
message(false);
var circle = { title: $("#title").val(), users: $("#users").val() } ;
var circle = { title: $("#title").val(), members: $("#users").val() } ;
$("#title").text('');
$("#users").val('');
$.ajax({
@ -149,8 +154,8 @@ function selectCircle() {
$('<tr id="c_'+id+'"/>').addClass('selected row')
.appendTo('#tbcb');
$('<td>'+circle.title+'<br><i>'+
circle.users+
$('<td>'+circle.title+' <br><i>'+
circle.members+
'</i></td></td>')
.appendTo('#c_'+id);

@ -658,7 +658,7 @@ CREATE TABLE circle
owner character varying(255) NOT NULL, -- creator of this circle
applicationname character varying(255) NOT NULL, -- Application name
title character varying(512) NOT NULL,
public boolean, -- true when this circle is a public circle, from which the title would be available from an anonymous access to the owner's profile
public boolean default FALSE, -- true when this circle is a public circle, from which the title would be available from an anonymous access to the owner's profile
CONSTRAINT circle_pkey PRIMARY KEY (_id),
CONSTRAINT circle_owner_fkey FOREIGN KEY (owner, applicationname)
REFERENCES users (username, applicationname) MATCH SIMPLE
@ -673,7 +673,6 @@ COMMENT ON COLUMN circle.owner IS 'creator of this circle';
COMMENT ON COLUMN circle.applicationname IS 'Application name';
COMMENT ON COLUMN circle.public IS 'true when this circle is a public circle, from which the title would be available from an anonymous access to the owner''s profile';
-- Table: circle_members
-- DROP TABLE circle_members;

@ -44,23 +44,16 @@ namespace Yavsc.Model.Circles
public abstract long Create(string owner, string title, string [] users);
/// <summary>
/// Add the specified user.
/// Add the specified user to the specified circle.
/// </summary>
/// <param name="id">circle Identifier.</param>
/// <param name="username">User name.</param>
public abstract void Add(long id, string username);
/// <summary>
/// Remove the specified user.
/// Delete the specified circle by its id.
/// </summary>
/// <param name="id">circle Identifier.</param>
/// <param name="username">User name.</param>
public abstract void Remove(long id, string username);
/// <summary>
/// Delete the specified id.
/// </summary>
/// <param name="id">Identifier.</param>
/// <param name="id">Circle Identifier.</param>
public abstract void Delete(long id) ;
/// <summary>
@ -70,17 +63,31 @@ namespace Yavsc.Model.Circles
public abstract Circle Get(long id);
/// <summary>
/// List this instance.
/// List circle's user.
/// </summary>
public abstract IEnumerable<Circle> List(string user);
/// <summary>
/// Covers the specified username.
/// True when the specified user is listed in one of
/// the specified circles
/// </summary>
/// <param name="circle_ids">circle's owner.</param>
/// <param name="member">Username in his circle.</param>
/// <param name="circle_ids">circles to look at</param>
/// <param name="member">Username to look for in the circles</param>
public abstract bool Matches(long [] circle_ids, string member);
/// <summary>
/// Removes the membership.
/// </summary>
/// <param name="circle_id">Circle identifier.</param>
/// <param name="member">Member.</param>
public abstract void RemoveMembership(long circle_id, string member);
/// <summary>
/// Removes the member from all current user circles.
/// </summary>
/// <param name="member">Member.</param>
public abstract void RemoveMember(string member);
}
}

@ -1,48 +0,0 @@
//
// ListItem.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
//
// Copyright (c) 2015 GNU GPL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace Yavsc.Model
{
/// <summary>
/// List item.
/// </summary>
[Obsolete("Use MVC SelectItem")]
public class ListItem
{
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
public string Value { get; set; }
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
public string Text { get; set; }
/// <summary>
/// Gets or sets the icon.
/// </summary>
/// <value>The icon.</value>
public string Icon { get; set; }
}
}

@ -153,7 +153,6 @@
<Compile Include="RolesAndMembers\GCMRegister.cs" />
<Compile Include="RolesAndMembers\LostPasswordModel.cs" />
<Compile Include="Messaging\SimpleMessage.cs" />
<Compile Include="ListItem.cs" />
<Compile Include="Calendar\BookEdit.cs" />
<Compile Include="Calendar\FreeDate.cs" />
<Compile Include="FrontOffice\Catalog\Billing\PriceOnItemCount.cs" />

Loading…