diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e98c498d --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*/bin +*/obj +plugins/*/bin +plugins/*/obj +*.userprefs +packages +web/avatars +web/users +web/Web References +build +.nuget +.gitignore + diff --git a/NpgsqlContentProvider/NpgsqlCircleProvider.cs b/NpgsqlContentProvider/NpgsqlCircleProvider.cs index 75cbe039..3d6fc23b 100644 --- a/NpgsqlContentProvider/NpgsqlCircleProvider.cs +++ b/NpgsqlContentProvider/NpgsqlCircleProvider.cs @@ -36,6 +36,28 @@ namespace WorkFlowProvider /// 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 + /// /// Initializes a new instance of the class. /// @@ -88,23 +110,6 @@ namespace WorkFlowProvider } } - /// - /// Remove the specified user. - /// - /// circle Identifier. - /// User name. - 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 (); - } - } /// /// Get the specified id. diff --git a/web/ApiControllers/AuthorizationDenied.cs b/web/ApiControllers/AuthorizationDenied.cs index 1b90bc37..2193e6aa 100644 --- a/web/ApiControllers/AuthorizationDenied.cs +++ b/web/ApiControllers/AuthorizationDenied.cs @@ -44,7 +44,7 @@ namespace Yavsc.ApiControllers public class AuthorizationDenied : HttpRequestException { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the Yavsc.ApiControllers.AuthorizationDenied class. /// /// Message. public AuthorizationDenied(string msg) : base(msg) diff --git a/web/ApiControllers/CircleController.cs b/web/ApiControllers/CircleController.cs index a2e30521..18490ad8 100644 --- a/web/ApiControllers/CircleController.cs +++ b/web/ApiControllers/CircleController.cs @@ -29,26 +29,6 @@ using Yavsc.Model; namespace Yavsc.ApiControllers { - /// - /// New circle. - /// - public class NewCircle { - /// - /// Gets or sets the title. - /// - /// The title. - public string title { get ; set; } - /// - /// Gets or sets the users. - /// - /// The users. - public string [] users { get ; set; } - /// - /// Gets or sets a value indicating whether this is private. - /// - /// true if is private; otherwise, false. - public bool isPrivate { get; set; } - } /// /// Circle controller. @@ -62,10 +42,10 @@ namespace Yavsc.ApiControllers /// Model. [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); } /// @@ -94,6 +74,20 @@ namespace Yavsc.ApiControllers CircleManager.DefaultProvider.Delete (id); } + + /// + /// Removes the user from circle. + /// + /// Identifier. + /// Username. + [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; diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index 763b5118..0aaba7b5 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -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; diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index afd4c1e7..e2876f3d 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -214,12 +214,13 @@ namespace Yavsc.Controllers return View (model); } - /// - /// Profile the specified user. - /// - /// User name. + [Authorize] [HttpGet] + /// + /// Profile the specified id. + /// + /// Identifier. public ActionResult Profile (string id) { if (id == null) @@ -230,14 +231,16 @@ namespace Yavsc.Controllers return View (model); } - /// - /// Profile the specified user, model and AvatarFile. - /// - /// User. - /// Model. - /// Avatar file. + + [Authorize] [HttpPost] + /// + /// Profile the specified id, model and AvatarFile. + /// + /// Identifier. + /// Model. + /// Avatar file. public ActionResult Profile (string id, Profile model, HttpPostedFileBase AvatarFile) { // ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash" diff --git a/web/Scripts/MarkdownDeep License.txt b/web/Scripts/MarkdownDeep License.txt new file mode 100644 index 00000000..3787ba80 --- /dev/null +++ b/web/Scripts/MarkdownDeep License.txt @@ -0,0 +1,16 @@ +MarkdownDeep License +==================== + +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 + + + +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. + + diff --git a/web/Scripts/MarkdownDeep Quick Reference.txt b/web/Scripts/MarkdownDeep Quick Reference.txt new file mode 100644 index 00000000..f8a2ff58 --- /dev/null +++ b/web/Scripts/MarkdownDeep Quick Reference.txt @@ -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: + + + + + +2. Insert the following markup at the location you want the editor to appear: + +
+ <%=Html.TextArea("content", new { @class="mdd_editor" }) %> +
+
+ + 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 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 for other methods and properties. diff --git a/web/Scripts/mdd_ajax_loader.gif b/web/Scripts/mdd_ajax_loader.gif new file mode 100644 index 00000000..02932f1a Binary files /dev/null and b/web/Scripts/mdd_ajax_loader.gif differ diff --git a/web/Scripts/mdd_gripper.png b/web/Scripts/mdd_gripper.png new file mode 100644 index 00000000..b581f2ef Binary files /dev/null and b/web/Scripts/mdd_gripper.png differ diff --git a/web/Scripts/mdd_help.htm b/web/Scripts/mdd_help.htm new file mode 100644 index 00000000..65fadc92 --- /dev/null +++ b/web/Scripts/mdd_help.htm @@ -0,0 +1,166 @@ +

Markdown Formatting

+

Markdown turns plain text formatting into fancy HTML formatting.

+

Phrase Emphasis

+
*italic*   **bold**
+_italic_   __bold__
+
+ +

Links

+

Inline:

+
An [example](http://url.com/ "Title")
+
+ +

Reference-style labels (titles are optional):

+
An [example][id]. Then, anywhere
+else in the doc, define the link:
+
+  [id]: http://example.com/  "Title"
+
+ +

Images

+

Inline (titles are optional):

+
![alt text](/path/img.jpg "Title")
+
+ +

Reference-style:

+
![alt text][id]
+
+[id]: /url/to/img.jpg "Title"
+
+ +

Headers

+

Setext-style:

+
Header 1
+========
+
+Header 2
+--------
+
+ +

atx-style (closing #'s are optional):

+
# Header 1 #
+
+## Header 2 ##
+
+###### Header 6
+
+ +

Lists

+

Ordered, without paragraphs:

+
1.  Foo
+2.  Bar
+
+ +

Unordered, with paragraphs:

+
*   A list item.
+
+    With multiple paragraphs.
+
+*   Bar
+
+ +

You can nest them:

+
*   Abacus
+    * answer
+*   Bubbles
+    1.  bunk
+    2.  bupkis
+        * BELITTLER
+    3. burper
+*   Cunning
+
+ +

Blockquotes

+
> Email-style angle brackets
+> are used for blockquotes.
+
+> > And, they can be nested.
+
+> #### Headers in blockquotes
+> 
+> * You can quote a list.
+> * Etc.
+
+ +

Code Spans

+
`<code>` spans are delimited
+by backticks.
+
+You can include literal backticks
+like `` `this` ``.
+
+ +

Preformatted Code Blocks

+

Indent every line of a code block by at least 4 spaces or 1 tab.

+
This is a normal paragraph.
+
+    This is a preformatted
+    code block.
+
+ +

Horizontal Rules

+

Three or more dashes or asterisks:

+
---
+
+* * *
+
+- - - - 
+
+ +

Manual Line Breaks

+

End a line with two or more spaces:

+
Roses are red,   
+Violets are blue.
+
+ +

Extra Mode

+ +These formatting features are only available when Extra Mode is enabled. + +

Markdown In Html

+

Enable markdown in HTML block level elements:

+
<div markdown="1">
+Markdown **still** works.
+</div>
+
+ +

Fenced Code Blocks

+

Code blocks delimited by 3 or more tildas:

+
~~~
+This is a preformatted
+code block
+~~~
+
+ +

Header IDs

+

Set the id of headings with {#<id>} at end of heading line:

+
## My Heading {#myheading}
+
+ +

Tables

+ +
Fruit    |Color
+---------|----------
+Apples   |Red
+Pears	 |Green
+Bananas  |Yellow
+

Definition Lists

+
Term 1
+: Definition 1
+
+Term 2
+: Definition 2
+ +

Footnotes

+
Body text with a footnote [^1]
+
+[^1]: Footnote text here
+
+ +

Abbreviations

+
MDD <- will have title
+
+*[MDD]: MarkdownDeep
+
+

 

+ diff --git a/web/Scripts/mdd_modal_background.png b/web/Scripts/mdd_modal_background.png new file mode 100644 index 00000000..9f8cc70b Binary files /dev/null and b/web/Scripts/mdd_modal_background.png differ diff --git a/web/Scripts/mdd_styles.css b/web/Scripts/mdd_styles.css new file mode 100644 index 00000000..9982faa7 --- /dev/null +++ b/web/Scripts/mdd_styles.css @@ -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; +} + diff --git a/web/Scripts/mdd_toolbar.png b/web/Scripts/mdd_toolbar.png new file mode 100644 index 00000000..74ecbc99 Binary files /dev/null and b/web/Scripts/mdd_toolbar.png differ diff --git a/web/Views/Account/Circles.aspx b/web/Views/Account/Circles.aspx index eb76e0b6..984fda86 100644 --- a/web/Views/Account/Circles.aspx +++ b/web/Views/Account/Circles.aspx @@ -43,7 +43,7 @@ $("#tbc").stupidtable(); - + @@ -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() { $('').addClass('selected row') .appendTo('#tbcb'); - $('') .appendTo('#c_'+id); diff --git a/web/instdbws.sql b/web/instdbws.sql index 84385232..f9250137 100644 --- a/web/instdbws.sql +++ b/web/instdbws.sql @@ -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; diff --git a/yavscModel/Circles/CircleProvider.cs b/yavscModel/Circles/CircleProvider.cs index b3ae6ff5..c68c7aff 100644 --- a/yavscModel/Circles/CircleProvider.cs +++ b/yavscModel/Circles/CircleProvider.cs @@ -44,23 +44,16 @@ namespace Yavsc.Model.Circles public abstract long Create(string owner, string title, string [] users); /// - /// Add the specified user. + /// Add the specified user to the specified circle. /// /// circle Identifier. /// User name. public abstract void Add(long id, string username); /// - /// Remove the specified user. + /// Delete the specified circle by its id. /// - /// circle Identifier. - /// User name. - public abstract void Remove(long id, string username); - - /// - /// Delete the specified id. - /// - /// Identifier. + /// Circle Identifier. public abstract void Delete(long id) ; /// @@ -70,17 +63,31 @@ namespace Yavsc.Model.Circles public abstract Circle Get(long id); /// - /// List this instance. + /// List circle's user. /// public abstract IEnumerable List(string user); /// - /// Covers the specified username. + /// True when the specified user is listed in one of + /// the specified circles /// - /// circle's owner. - /// Username in his circle. + /// circles to look at + /// Username to look for in the circles public abstract bool Matches(long [] circle_ids, string member); + /// + /// Removes the membership. + /// + /// Circle identifier. + /// Member. + public abstract void RemoveMembership(long circle_id, string member); + + /// + /// Removes the member from all current user circles. + /// + /// Member. + public abstract void RemoveMember(string member); + } } diff --git a/yavscModel/ListItem.cs b/yavscModel/ListItem.cs deleted file mode 100644 index 75612e3e..00000000 --- a/yavscModel/ListItem.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// ListItem.cs -// -// Author: -// Paul Schneider -// -// 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 . -using System; - -namespace Yavsc.Model -{ - /// - /// List item. - /// - [Obsolete("Use MVC SelectItem")] - public class ListItem - { - /// - /// Gets or sets the value. - /// - /// The value. - public string Value { get; set; } - /// - /// Gets or sets the text. - /// - /// The text. - public string Text { get; set; } - /// - /// Gets or sets the icon. - /// - /// The icon. - public string Icon { get; set; } - } -} - diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index 9fdbfdb4..b0f87748 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -153,7 +153,6 @@ -
'+circle.title+'
'+ - circle.users+ + $('
'+circle.title+'
'+ + circle.members+ '