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
This commit is contained in:
@ -94,6 +94,7 @@ namespace Yavsc.ApiControllers
|
||||
string root = HttpContext.Current.Server.MapPath("~/bfiles/"+id);
|
||||
DirectoryInfo di = new DirectoryInfo (root);
|
||||
if (!di.Exists) di.Create ();
|
||||
|
||||
var provider = new MultipartFormDataStreamProvider(root);
|
||||
try
|
||||
{
|
||||
@ -105,12 +106,15 @@ namespace Yavsc.ApiControllers
|
||||
string filename = provider.BodyPartFileNames[fkey];
|
||||
Trace.WriteLine(filename);
|
||||
|
||||
string nicename=fkey;
|
||||
string nicename = HttpUtility.UrlDecode(fkey) ;
|
||||
if (fkey.StartsWith("\"") && fkey.EndsWith("\"") && fkey.Length > 2)
|
||||
nicename = fkey.Substring(1,fkey.Length-2);
|
||||
var filtered = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray());
|
||||
File.Move(Path.Combine(root,filename),
|
||||
Path.Combine(root,filtered));
|
||||
nicename = new string (nicename.Where( x=> !invalidChars.Contains(x)).ToArray());
|
||||
nicename = nicename.Replace(' ','_');
|
||||
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);
|
||||
|
@ -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>
|
||||
|
||||
* 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 = [
|
||||
'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) {
|
||||
@ -489,8 +489,16 @@ module.exports = [
|
||||
{
|
||||
filter: 'audio',
|
||||
replacement: function(content, node) {
|
||||
var alt = node.alt || '';
|
||||
var alt = node.getAttribute("alt") || '';
|
||||
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 titlePart = title ? ' "'+ title +'"' : '';
|
||||
return src ? '![audio:' + alt + ']' + '(' + src + titlePart + ')' : '';
|
||||
|
@ -26,11 +26,11 @@ namespace Yavsc
|
||||
{
|
||||
cnx.Open ();
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText = "drop table testbytea";
|
||||
cmd.CommandText = "drop table _testbytea";
|
||||
try { cmd.ExecuteNonQuery (); }
|
||||
catch (NpgsqlException) {
|
||||
}
|
||||
cmd.CommandText = "create table testbytea( t bytea )";
|
||||
cmd.CommandText = "create table _testbytea( t bytea )";
|
||||
cmd.ExecuteNonQuery ();
|
||||
}
|
||||
}
|
||||
@ -47,14 +47,14 @@ namespace Yavsc
|
||||
cnx.Open ();
|
||||
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.ExecuteNonQuery ();
|
||||
}
|
||||
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ())
|
||||
{
|
||||
cmd.CommandText = "select t from testbytea";
|
||||
cmd.CommandText = "select t from _testbytea";
|
||||
cmd.Parameters.AddWithValue ("@tv", a);
|
||||
|
||||
NpgsqlDataReader rdr = cmd.ExecuteReader ();
|
||||
@ -77,7 +77,7 @@ namespace Yavsc
|
||||
using (NpgsqlConnection cnx = new NpgsqlConnection (ConnectionString)) {
|
||||
cnx.Open ();
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText = "drop table testbytea";
|
||||
cmd.CommandText = "drop table _testbytea";
|
||||
cmd.ExecuteNonQuery ();
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
<%=Html.Hidden("Id")%>
|
||||
<input type="submit">
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
jQuery('#vtitle').hallo({
|
||||
plugins: {
|
||||
@ -54,8 +55,8 @@ var markdownize = function(content) {
|
||||
}).join("\n");
|
||||
return toMarkdown(html);
|
||||
};
|
||||
var converter = new Showdown.converter();
|
||||
var htmlize = function(content) {
|
||||
var converter = new showdown.Converter(),
|
||||
htmlize = function(content) {
|
||||
return converter.makeHtml(content);
|
||||
};
|
||||
|
||||
|
@ -270,7 +270,6 @@
|
||||
<Content Include="Scripts\rangyinputs-jquery-1.1.2.js" />
|
||||
<Content Include="images\sign-in-with-google.png" />
|
||||
<Content Include="Views\Account\Unregister.aspx" />
|
||||
<Content Include="Scripts\GruntFile.js" />
|
||||
<Content Include="Scripts\jquery.timepicker.js" />
|
||||
<Content Include="Scripts\jquery.timepicker.min.js" />
|
||||
<Content Include="Scripts\jquery.mousewheel.js" />
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user