blog mef
This commit is contained in:
parent
0af12186e7
commit
c6acf07c09
26 changed files with 183 additions and 72 deletions
|
|
@ -64,7 +64,7 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
return View(posts
|
return View(posts
|
||||||
.OrderByDescending(p => p.DateCreated)
|
.OrderByDescending(p => p.DateCreated)
|
||||||
.Skip(skip).Take(maxLen));
|
.Skip(skip).Take(maxLen).GroupBy(p=>p.Title));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Title/{id?}")]
|
[Route("/Title/{id?}")]
|
||||||
|
|
@ -72,7 +72,8 @@ namespace Yavsc.Controllers
|
||||||
public IActionResult Title(string id)
|
public IActionResult Title(string id)
|
||||||
{
|
{
|
||||||
var uid = User.GetUserId();
|
var uid = User.GetUserId();
|
||||||
return View("Index", _context.Blogspot.Include(
|
ViewData["Title"] = id;
|
||||||
|
return View("Title", _context.Blogspot.Include(
|
||||||
b => b.Author
|
b => b.Author
|
||||||
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).ToList());
|
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).ToList());
|
||||||
}
|
}
|
||||||
|
|
@ -81,17 +82,19 @@ namespace Yavsc.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public IActionResult UserPosts(string id)
|
public IActionResult UserPosts(string id)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(id))
|
|
||||||
return View("Index",_context.Blogspot.Include(
|
if (string.IsNullOrEmpty(id)) return Index(null);
|
||||||
b => b.Author
|
var uid = User.GetUserId();
|
||||||
).Where(p => p.Visible));
|
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||||
if (User.IsSignedIn())
|
.Select(c=>c.Id).ToArray();
|
||||||
return View("Index", _context.Blogspot.Include(
|
var result = (User.IsSignedIn())?
|
||||||
|
_context.Blogspot.Include(
|
||||||
b => b.Author
|
b => b.Author
|
||||||
).Where(x => x.Author.UserName == id).ToList());
|
).Include(p=>p.ACL).Where(x => x.Author.UserName == id && (x.Visible && (x.ACL.Count==0 || x.ACL.Any(a=> usercircles.Contains(a.CircleId))))):
|
||||||
return View("Index", _context.Blogspot.Include(
|
_context.Blogspot.Include(
|
||||||
b => b.Author
|
b => b.Author
|
||||||
).Where(x => x.Author.UserName == id && x.Visible).ToList());
|
).Where(x => x.Author.UserName == id && x.Visible);
|
||||||
|
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=>p.Title));
|
||||||
}
|
}
|
||||||
// GET: Blog/Details/5
|
// GET: Blog/Details/5
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
|
@ -118,9 +121,10 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
// GET: Blog/Create
|
// GET: Blog/Create
|
||||||
[Authorize()]
|
[Authorize()]
|
||||||
public IActionResult Create()
|
public IActionResult Create(string title)
|
||||||
{
|
{
|
||||||
return View();
|
var result = new Blog{Title=title};
|
||||||
|
return View(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: Blog/Create
|
// POST: Blog/Create
|
||||||
|
|
@ -130,6 +134,7 @@ namespace Yavsc.Controllers
|
||||||
blog.Rate = 0;
|
blog.Rate = 0;
|
||||||
blog.AuthorId = User.GetUserId();
|
blog.AuthorId = User.GetUserId();
|
||||||
ModelState.ClearValidationState("AuthorId");
|
ModelState.ClearValidationState("AuthorId");
|
||||||
|
blog.Id=0;
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
_context.Blogspot.Add(blog);
|
_context.Blogspot.Add(blog);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<h2>Create</h2>
|
<h2>Create</h2>
|
||||||
|
|
||||||
<form asp-action="Create" role="form">
|
<form asp-action="Create" role="form" method="POST">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<h4>Blog</h4>
|
<h4>Blog</h4>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,41 @@
|
||||||
@model IEnumerable<Blog>
|
@model IEnumerable<IGrouping<string,Blog>>
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Index";
|
ViewData["Title"] = "Blogs, l'index";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>Index</h2>
|
<h2>@ViewData["Title"]</h2>
|
||||||
<p class="text-success">@ViewData["StatusMessage"]</p>
|
<p class="text-success">@ViewData["StatusMessage"]</p>
|
||||||
@if (User.IsSignedIn()) {
|
@if (User.IsSignedIn()) {
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="cbv" checked/>Invisibles, posts privés</label>
|
<input type="checkbox" id="cbv" checked/>Invisibles, posts privés</label>
|
||||||
<script>
|
<script>
|
||||||
$("#cbv").change(function() {
|
$("#cbv").change(function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
$("tr.hiddenpost").removeClass("hidden");
|
$("tr.hiddenpost").removeClass("hidden");
|
||||||
} else {
|
} else {
|
||||||
$("tr.hiddenpost").addClass("hidden");
|
$("tr.hiddenpost").addClass("hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="Create">@SR["Create a new article"]</a>
|
<a asp-action="Create">@SR["Create a new article"]</a>
|
||||||
</p>
|
</p>
|
||||||
|
}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3">
|
<th colspan="3">
|
||||||
@SR[Html.DisplayNameFor(model => model.Title)]
|
@SR["Title"]
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@foreach (var item in Model) {
|
@foreach (var group in Model) {
|
||||||
|
var title = group.Key;
|
||||||
|
@foreach (var item in group) {
|
||||||
var trclass = (item.Visible)?"visiblepost":"hiddenpost";
|
var trclass = (item.Visible)?"visiblepost":"hiddenpost";
|
||||||
|
|
||||||
<tr class="@trclass">
|
<tr class="@trclass">
|
||||||
<td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
|
<td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
|
||||||
<img src="@item.Photo" class="smalltofhol">
|
<img src="@item.Photo" class="smalltofhol"></a>
|
||||||
|
<a asp-action="Title" asp-route-id="@item.Title">
|
||||||
<markdown>@item.Title</markdown></a>
|
<markdown>@item.Title</markdown></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
61
Yavsc/Views/Blogspot/Title.cshtml
Normal file
61
Yavsc/Views/Blogspot/Title.cshtml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
@model IEnumerable<Blog>
|
||||||
|
|
||||||
|
<h2 markdown="@ViewData["Title"]"></h2>
|
||||||
|
<p class="text-success">@ViewData["StatusMessage"]</p>
|
||||||
|
@if (User.IsSignedIn()) {
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="cbv" checked/>Invisibles, posts privés</label>
|
||||||
|
<script>
|
||||||
|
$("#cbv").change(function() {
|
||||||
|
if (this.checked) {
|
||||||
|
$("tr.hiddenpost").removeClass("hidden");
|
||||||
|
} else {
|
||||||
|
$("tr.hiddenpost").addClass("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
}
|
||||||
|
<p>
|
||||||
|
<a asp-action="Create" asp-route-title="@ViewData["Title"]">@SR["Poster au même titre"]</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
|
||||||
|
@foreach (var item in Model) {
|
||||||
|
var trclass = (item.Visible)?"visiblepost":"hiddenpost";
|
||||||
|
|
||||||
|
<tr class="@trclass">
|
||||||
|
<td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
|
||||||
|
<img src="@item.Photo" class="smalltofhol"></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<markdown>@((item.Content?.Length > 120) ? item.Content.Substring(0, 122) + " ..." : item.Content)</markdown>
|
||||||
|
<span style="font-size:x-small;">(@item.Author.UserName </span>,
|
||||||
|
<span style="font-size:xx-small;">
|
||||||
|
posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm")
|
||||||
|
@if ((item.DateModified - item.DateCreated).Minutes > 0){
|
||||||
|
@:- Modifié le @item.DateModified.ToString("dddd d MMM yyyy à H:mm")
|
||||||
|
})
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul class="actiongroup">
|
||||||
|
@if (await AuthorizationService.AuthorizeAsync(User, item, new ViewRequirement())) {
|
||||||
|
<li>
|
||||||
|
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-lg">Details</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
@if (await AuthorizationService.AuthorizeAsync(User, item, new EditRequirement())) {
|
||||||
|
<li><a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-default">@SR["Edit"]</a>
|
||||||
|
</li>
|
||||||
|
<li><a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">@SR["Delete"]</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -6,7 +6,8 @@ var gulp = require("gulp"),
|
||||||
concat = require("gulp-concat"),
|
concat = require("gulp-concat"),
|
||||||
cssmin = require("gulp-cssmin"),
|
cssmin = require("gulp-cssmin"),
|
||||||
uglify = require("gulp-uglify"),
|
uglify = require("gulp-uglify"),
|
||||||
shell = require("gulp-shell");
|
shell = require("gulp-shell"),
|
||||||
|
rename = require('gulp-rename');
|
||||||
|
|
||||||
var webroot = "./wwwroot/";
|
var webroot = "./wwwroot/";
|
||||||
|
|
||||||
|
|
@ -48,9 +49,22 @@ gulp.task("min:css", function () {
|
||||||
|
|
||||||
gulp.task("min", ["min:js", "min:css"]);
|
gulp.task("min", ["min:js", "min:css"]);
|
||||||
|
|
||||||
gulp.task('watch', shell.task(['ASPNET_ENV=Development dnx-watch web --configuration=Debug']))
|
gulp.task('watch:web', shell.task(['ASPNET_ENV=Development dnx-watch web --configuration=Debug']));
|
||||||
|
gulp.task('watch:lua', shell.task(['ASPNET_ENV=Lua dnx-watch luatest --configuration=Debug']));
|
||||||
gulp.task('build', shell.task(['dnu build --configuration=Debug']))
|
|
||||||
gulp.task('publish', shell.task(['dnu publish -o ../build']))
|
|
||||||
|
|
||||||
|
gulp.task('build', shell.task(['dnu build --configuration=Debug']));
|
||||||
|
gulp.task('publish', shell.task(['dnu publish']));
|
||||||
|
|
||||||
|
gulp.task("amincss", function () {
|
||||||
|
gulp.src([paths.css, "!" + paths.minCss, '!site.css'])
|
||||||
|
.pipe(cssmin())
|
||||||
|
.pipe(rename({suffix: '.min'}))
|
||||||
|
.pipe(gulp.dest('wwwroot/css'));
|
||||||
|
});
|
||||||
|
gulp.task("aminjs", function () {
|
||||||
|
return gulp.src([paths.js, "!" + paths.minJs, '!site.js'])
|
||||||
|
.pipe(uglify())
|
||||||
|
.pipe(rename({suffix: '.min'}))
|
||||||
|
.pipe(gulp.dest('wwwroot/js'));
|
||||||
|
});
|
||||||
|
gulp.task("default",['amincss','aminjs']);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"grunt": "^1.0.1",
|
"grunt": "^1.0.1",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-concat": "2.5.2",
|
"gulp-concat": "2.5.2",
|
||||||
"gulp-cssmin": "0.1.7",
|
"gulp-cssmin": "^0.1.7",
|
||||||
"gulp-dnx-tasks": "^1.0.0-beta7",
|
"gulp-dnx-tasks": "^1.0.0-beta7",
|
||||||
"gulp-shell": "^0.5.2",
|
"gulp-shell": "^0.5.2",
|
||||||
"gulp-uglify": "1.2.0",
|
"gulp-uglify": "1.2.0",
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@
|
||||||
"commands": {
|
"commands": {
|
||||||
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://*:5000",
|
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://*:5000",
|
||||||
"lua": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:85",
|
"lua": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:85",
|
||||||
|
"luatest": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:5001",
|
||||||
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:5000",
|
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:5000",
|
||||||
"zicmoove": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:87",
|
"zicmoove": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:87",
|
||||||
"yavsc": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:86",
|
"yavsc": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://*:86",
|
||||||
|
|
|
||||||
4
Yavsc/wwwroot/css/bootstrap.css
vendored
4
Yavsc/wwwroot/css/bootstrap.css
vendored
|
|
@ -3383,7 +3383,7 @@ fieldset[disabled] .btn-warning.active {
|
||||||
}
|
}
|
||||||
.btn-danger {
|
.btn-danger {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #d9534f;
|
background-color: #9b2a27;
|
||||||
border-color: #d43f3a;
|
border-color: #d43f3a;
|
||||||
}
|
}
|
||||||
.btn-danger:focus,
|
.btn-danger:focus,
|
||||||
|
|
@ -3414,7 +3414,7 @@ fieldset[disabled] .btn-warning.active {
|
||||||
.btn-danger.active.focus,
|
.btn-danger.active.focus,
|
||||||
.open > .dropdown-toggle.btn-danger.focus {
|
.open > .dropdown-toggle.btn-danger.focus {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #ac2925;
|
background-color: #9b2a27;
|
||||||
border-color: #761c19;
|
border-color: #761c19;
|
||||||
}
|
}
|
||||||
.btn-danger:active,
|
.btn-danger:active,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
2
Yavsc/wwwroot/css/bootstrap.min.css
vendored
2
Yavsc/wwwroot/css/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
1
Yavsc/wwwroot/css/dropzone.min.css
vendored
Normal file
1
Yavsc/wwwroot/css/dropzone.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
Yavsc/wwwroot/css/jquery-ui.min.css
vendored
Normal file
5
Yavsc/wwwroot/css/jquery-ui.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
Yavsc/wwwroot/css/quill.snow.min.css
vendored
Normal file
5
Yavsc/wwwroot/css/quill.snow.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@
|
||||||
body {
|
body {
|
||||||
/* background-color: #04264f;
|
/* background-color: #04264f;
|
||||||
color:#000;*/
|
color:#000;*/
|
||||||
background-color: #210912;
|
background-color: #080225;
|
||||||
color:#999;
|
color:#999;
|
||||||
}
|
}
|
||||||
h1,h2,h3,h4,h5,h6{color:#fff;}
|
h1,h2,h3,h4,h5,h6{color:#fff;}
|
||||||
|
|
|
||||||
4
Yavsc/wwwroot/css/site.min.css
vendored
4
Yavsc/wwwroot/css/site.min.css
vendored
File diff suppressed because one or more lines are too long
13
Yavsc/wwwroot/css/site.min.min.css
vendored
Normal file
13
Yavsc/wwwroot/css/site.min.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
Yavsc/wwwroot/js/bootstrap.min.js
vendored
Normal file
2
Yavsc/wwwroot/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
Yavsc/wwwroot/js/dropzone.min.js
vendored
Normal file
3
Yavsc/wwwroot/js/dropzone.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
Yavsc/wwwroot/js/jquery-ui.min.js
vendored
Normal file
11
Yavsc/wwwroot/js/jquery-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
Yavsc/wwwroot/js/jquery.min.js
vendored
Normal file
4
Yavsc/wwwroot/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
Yavsc/wwwroot/js/jquery.signalR-2.2.1.min.js
vendored
Normal file
3
Yavsc/wwwroot/js/jquery.signalR-2.2.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Yavsc/wwwroot/js/md-helpers.min.js
vendored
Normal file
1
Yavsc/wwwroot/js/md-helpers.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
var markdownize=function(r){if(!r)return"";var n=r.split("\n").map($.trim).filter(function(r){return""!=r}).join("\n");return toMarkdown(n)},converter=new showdown.Converter,htmlize=function(r){return converter.makeHtml(r)},updateMD=function(r,n){if(!n)return jQuery("#"+r).val("");var e=markdownize(n);jQuery("#"+r).val()!==e&&jQuery("#"+r).val(e)};
|
||||||
5
Yavsc/wwwroot/js/quill.min.js
vendored
Normal file
5
Yavsc/wwwroot/js/quill.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Yavsc/wwwroot/js/showdown.min.js
vendored
Normal file
1
Yavsc/wwwroot/js/showdown.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
27
Yavsc/wwwroot/js/site.min.js
vendored
Normal file → Executable file
27
Yavsc/wwwroot/js/site.min.js
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
1
Yavsc/wwwroot/js/to-markdown.min.js
vendored
Normal file
1
Yavsc/wwwroot/js/to-markdown.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue