This commit is contained in:
2017-03-11 01:06:42 +01:00
parent d6f72ba20f
commit a2172da6ff
26 changed files with 183 additions and 72 deletions

View File

@ -64,7 +64,7 @@ namespace Yavsc.Controllers
return View(posts
.OrderByDescending(p => p.DateCreated)
.Skip(skip).Take(maxLen));
.Skip(skip).Take(maxLen).GroupBy(p=>p.Title));
}
[Route("/Title/{id?}")]
@ -72,7 +72,8 @@ namespace Yavsc.Controllers
public IActionResult Title(string id)
{
var uid = User.GetUserId();
return View("Index", _context.Blogspot.Include(
ViewData["Title"] = id;
return View("Title", _context.Blogspot.Include(
b => b.Author
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).ToList());
}
@ -81,17 +82,19 @@ namespace Yavsc.Controllers
[AllowAnonymous]
public IActionResult UserPosts(string id)
{
if (string.IsNullOrEmpty(id))
return View("Index",_context.Blogspot.Include(
b => b.Author
).Where(p => p.Visible));
if (User.IsSignedIn())
return View("Index", _context.Blogspot.Include(
if (string.IsNullOrEmpty(id)) return Index(null);
var uid = User.GetUserId();
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
.Select(c=>c.Id).ToArray();
var result = (User.IsSignedIn())?
_context.Blogspot.Include(
b => b.Author
).Where(x => x.Author.UserName == id).ToList());
return View("Index", _context.Blogspot.Include(
).Include(p=>p.ACL).Where(x => x.Author.UserName == id && (x.Visible && (x.ACL.Count==0 || x.ACL.Any(a=> usercircles.Contains(a.CircleId))))):
_context.Blogspot.Include(
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
[AllowAnonymous]
@ -118,9 +121,10 @@ namespace Yavsc.Controllers
// GET: Blog/Create
[Authorize()]
public IActionResult Create()
public IActionResult Create(string title)
{
return View();
var result = new Blog{Title=title};
return View(result);
}
// POST: Blog/Create
@ -130,6 +134,7 @@ namespace Yavsc.Controllers
blog.Rate = 0;
blog.AuthorId = User.GetUserId();
ModelState.ClearValidationState("AuthorId");
blog.Id=0;
if (ModelState.IsValid)
{
_context.Blogspot.Add(blog);

View File

@ -6,7 +6,7 @@
<h2>Create</h2>
<form asp-action="Create" role="form">
<form asp-action="Create" role="form" method="POST">
<div class="form-horizontal">
<h4>Blog</h4>
<hr />

View File

@ -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>
@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>
}
<script>
$("#cbv").change(function() {
if (this.checked) {
$("tr.hiddenpost").removeClass("hidden");
} else {
$("tr.hiddenpost").addClass("hidden");
}
});
</script>
<p>
<a asp-action="Create">@SR["Create a new article"]</a>
</p>
}
<table class="table">
<tr>
<th colspan="3">
@SR[Html.DisplayNameFor(model => model.Title)]
@SR["Title"]
</th>
</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";
<tr class="@trclass">
<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>
</td>
<td>
@ -65,6 +65,7 @@
</td>
</tr>
}
}
</table>

View 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>

View File

@ -6,7 +6,8 @@ var gulp = require("gulp"),
concat = require("gulp-concat"),
cssmin = require("gulp-cssmin"),
uglify = require("gulp-uglify"),
shell = require("gulp-shell");
shell = require("gulp-shell"),
rename = require('gulp-rename');
var webroot = "./wwwroot/";
@ -48,9 +49,22 @@ gulp.task("min:css", function () {
gulp.task("min", ["min:js", "min:css"]);
gulp.task('watch', shell.task(['ASPNET_ENV=Development dnx-watch web --configuration=Debug']))
gulp.task('build', shell.task(['dnu build --configuration=Debug']))
gulp.task('publish', shell.task(['dnu publish -o ../build']))
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']));
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']);

View File

@ -5,7 +5,7 @@
"grunt": "^1.0.1",
"gulp": "^3.9.0",
"gulp-concat": "2.5.2",
"gulp-cssmin": "0.1.7",
"gulp-cssmin": "^0.1.7",
"gulp-dnx-tasks": "^1.0.0-beta7",
"gulp-shell": "^0.5.2",
"gulp-uglify": "1.2.0",

View File

@ -115,6 +115,7 @@
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://*:5000",
"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",
"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",

View File

@ -3383,7 +3383,7 @@ fieldset[disabled] .btn-warning.active {
}
.btn-danger {
color: #fff;
background-color: #d9534f;
background-color: #9b2a27;
border-color: #d43f3a;
}
.btn-danger:focus,
@ -3414,7 +3414,7 @@ fieldset[disabled] .btn-warning.active {
.btn-danger.active.focus,
.open > .dropdown-toggle.btn-danger.focus {
color: #fff;
background-color: #ac2925;
background-color: #9b2a27;
border-color: #761c19;
}
.btn-danger:active,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

5
Yavsc/wwwroot/css/quill.snow.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
body {
/* background-color: #04264f;
color:#000;*/
background-color: #210912;
background-color: #080225;
color:#999;
}
h1,h2,h3,h4,h5,h6{color:#fff;}

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

4
Yavsc/wwwroot/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
Yavsc/wwwroot/js/md-helpers.min.js vendored Normal file
View 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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

1
Yavsc/wwwroot/js/to-markdown.min.js vendored Normal file

File diff suppressed because one or more lines are too long