Markdown video and audio, supported at client side

* BlogsController.cs: Fixes the Markdown usage of the uploaded
  files:
Files are now renamed by dropping invalid characters and replacing
  spaces by underscores.
An existing destination file is removed at upload.

* showdown.js: Renders audio and video at client side

* to-markdown.js: converts html audio and video to Markdown

* TestByteA.cs: adds a prefix, an underscore, to the test table
  `_testbytea`

* Edit.aspx: Uses the new `showdown` javascript module (that
  previously was named `Showdown`)

* Web.csproj: cleaning

* MarkdownDeep.dll: Renders video an audio

* GruntFile.js: Was pollution
main
Paul Schneider 10 years ago
parent 77149697dd
commit 9912d0cbb2
9 changed files with 2357 additions and 432 deletions

@ -94,6 +94,7 @@ namespace Yavsc.ApiControllers
string root = HttpContext.Current.Server.MapPath("~/bfiles/"+id); string root = HttpContext.Current.Server.MapPath("~/bfiles/"+id);
DirectoryInfo di = new DirectoryInfo (root); DirectoryInfo di = new DirectoryInfo (root);
if (!di.Exists) di.Create (); if (!di.Exists) di.Create ();
var provider = new MultipartFormDataStreamProvider(root); var provider = new MultipartFormDataStreamProvider(root);
try try
{ {
@ -105,12 +106,15 @@ namespace Yavsc.ApiControllers
string filename = provider.BodyPartFileNames[fkey]; string filename = provider.BodyPartFileNames[fkey];
Trace.WriteLine(filename); Trace.WriteLine(filename);
string nicename=fkey; string nicename = HttpUtility.UrlDecode(fkey) ;
if (fkey.StartsWith("\"") && fkey.EndsWith("\"") && fkey.Length > 2) if (fkey.StartsWith("\"") && fkey.EndsWith("\"") && fkey.Length > 2)
nicename = fkey.Substring(1,fkey.Length-2); nicename = fkey.Substring(1,fkey.Length-2);
var filtered = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray()); nicename = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray());
File.Move(Path.Combine(root,filename), nicename = nicename.Replace(' ','_');
Path.Combine(root,filtered)); var dest = Path.Combine(root,nicename);
var fi = new FileInfo(dest);
if (fi.Exists) fi.Delete();
File.Move(filename, fi.FullName);
} }
return Request.CreateResponse(HttpStatusCode.OK); return Request.CreateResponse(HttpStatusCode.OK);

@ -1,3 +1,28 @@
2015-09-25 Paul Schneider <paul@pschneider.fr>
* BlogsController.cs: Fixes the Markdown usage of the uploaded
files:
Files are now renamed by dropping invalid characters and
replacing spaces by underscores.
An existing destination file is removed at upload.
* showdown.js: Renders audio and video at client side
* to-markdown.js: converts html audio and video to Markdown
* TestByteA.cs: adds a prefix, an underscore, to the test
table `_testbytea`
* Edit.aspx: Uses the new `showdown` javascript module (that
previously was named `Showdown`)
* Web.csproj: cleaning
* MarkdownDeep.dll: Renders video an audio
* GruntFile.js: Was pollution
2015-09-23 Paul Schneider <paul@pschneider.fr> 2015-09-23 Paul Schneider <paul@pschneider.fr>
* font-awesome.css: an awesome css * font-awesome.css: an awesome css

@ -1,29 +0,0 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner : '/*!\n' +
' * <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> - <%= pkg.homepage %>\n' +
' * License: <%= pkg.license %>\n' +
' */\n\n'
},
uglify: {
options : {
banner : '<%= meta.banner %>',
report: 'gzip'
},
dist: {
files: {
'jquery.timepicker.min.js': ['jquery.timepicker.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};

File diff suppressed because it is too large Load Diff

@ -49,7 +49,7 @@ function isBlock(node) {
var voids = [ var voids = [
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', 'audio', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
]; ];
function isVoid(node) { function isVoid(node) {
@ -489,8 +489,16 @@ module.exports = [
{ {
filter: 'audio', filter: 'audio',
replacement: function(content, node) { replacement: function(content, node) {
var alt = node.alt || ''; var alt = node.getAttribute("alt") || '';
var src = node.getAttribute('src') || ''; var src = node.getAttribute('src') || '';
if (!src)
for (var i = 0; i < node.childNodes.length; i++)
{
if (node.childNodes[i].localName == 'source') {
src = node.childNodes[i].getAttribute('src') ;
break;
}
}
var title = node.title || ''; var title = node.title || '';
var titlePart = title ? ' "'+ title +'"' : ''; var titlePart = title ? ' "'+ title +'"' : '';
return src ? '![audio:' + alt + ']' + '(' + src + titlePart + ')' : ''; return src ? '![audio:' + alt + ']' + '(' + src + titlePart + ')' : '';

@ -26,11 +26,11 @@ namespace Yavsc
{ {
cnx.Open (); cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "drop table testbytea"; cmd.CommandText = "drop table _testbytea";
try { cmd.ExecuteNonQuery (); } try { cmd.ExecuteNonQuery (); }
catch (NpgsqlException) { catch (NpgsqlException) {
} }
cmd.CommandText = "create table testbytea( t bytea )"; cmd.CommandText = "create table _testbytea( t bytea )";
cmd.ExecuteNonQuery (); cmd.ExecuteNonQuery ();
} }
} }
@ -47,14 +47,14 @@ namespace Yavsc
cnx.Open (); cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) using (NpgsqlCommand cmd = cnx.CreateCommand ())
{ {
cmd.CommandText = "insert into testbytea (t) values (@tv)"; cmd.CommandText = "insert into _testbytea (t) values (@tv)";
cmd.Parameters.AddWithValue ("@tv", a); cmd.Parameters.AddWithValue ("@tv", a);
cmd.ExecuteNonQuery (); cmd.ExecuteNonQuery ();
} }
using (NpgsqlCommand cmd = cnx.CreateCommand ()) using (NpgsqlCommand cmd = cnx.CreateCommand ())
{ {
cmd.CommandText = "select t from testbytea"; cmd.CommandText = "select t from _testbytea";
cmd.Parameters.AddWithValue ("@tv", a); cmd.Parameters.AddWithValue ("@tv", a);
NpgsqlDataReader rdr = cmd.ExecuteReader (); NpgsqlDataReader rdr = cmd.ExecuteReader ();
@ -77,7 +77,7 @@ namespace Yavsc
using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString)) { using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString)) {
cnx.Open (); cnx.Open ();
using (NpgsqlCommand cmd = cnx.CreateCommand ()) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText = "drop table testbytea"; cmd.CommandText = "drop table _testbytea";
cmd.ExecuteNonQuery (); cmd.ExecuteNonQuery ();
} }
} }

@ -29,6 +29,7 @@
<%=Html.Hidden("Id")%> <%=Html.Hidden("Id")%>
<input type="submit"> <input type="submit">
<% } %> <% } %>
<script> <script>
jQuery('#vtitle').hallo({ jQuery('#vtitle').hallo({
plugins: { plugins: {
@ -54,8 +55,8 @@ var markdownize = function(content) {
}).join("\n"); }).join("\n");
return toMarkdown(html); return toMarkdown(html);
}; };
var converter = new Showdown.converter(); var converter = new showdown.Converter(),
var htmlize = function(content) { htmlize = function(content) {
return converter.makeHtml(content); return converter.makeHtml(content);
}; };

@ -270,7 +270,6 @@
<Content Include="Scripts\rangyinputs-jquery-1.1.2.js" /> <Content Include="Scripts\rangyinputs-jquery-1.1.2.js" />
<Content Include="images\sign-in-with-google.png" /> <Content Include="images\sign-in-with-google.png" />
<Content Include="Views\Account\Unregister.aspx" /> <Content Include="Views\Account\Unregister.aspx" />
<Content Include="Scripts\GruntFile.js" />
<Content Include="Scripts\jquery.timepicker.js" /> <Content Include="Scripts\jquery.timepicker.js" />
<Content Include="Scripts\jquery.timepicker.min.js" /> <Content Include="Scripts\jquery.timepicker.min.js" />
<Content Include="Scripts\jquery.mousewheel.js" /> <Content Include="Scripts\jquery.mousewheel.js" />

Binary file not shown.
Loading…