mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -9,4 +9,4 @@ b639cb33d2ba038de6048350400b664399608996 src/Orchard.Web/Modules/Orchard.Forms
|
||||
63dda71453ebbfd0e165662a0d56c9c0a7a3d3d4 src/Orchard.Web/Modules/Orchard.Tokens
|
||||
a47761330447df38f714bc17797b8895721a6974 src/orchard.web/Modules/Orchard.Alias
|
||||
80ada5dcf8158f432ce99fc3c7e76f5137e73473 src/orchard.web/Modules/Orchard.Projections
|
||||
163338f0bf6b1ae6c5d68c29fb828ce942ec24a1 src/orchard.web/modules/Orchard.Fields
|
||||
1cdac47b44aa7adaed8aa7f8c38324f1c9d89e1a src/orchard.web/modules/Orchard.Fields
|
||||
|
@@ -0,0 +1,22 @@
|
||||
using NUnit.Framework;
|
||||
using Orchard.Media.Helpers;
|
||||
|
||||
namespace Orchard.Tests.Modules.Media.Extensions {
|
||||
[TestFixture]
|
||||
public class MediaHelpersTests {
|
||||
[Test]
|
||||
public void PicturesArePictures() {
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.gif"), Is.True);
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.jpg"), Is.True);
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.jpeg"), Is.True);
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.png"), Is.True);
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.bmp"), Is.True);
|
||||
Assert.That(MediaHelpers.IsPicture(null, "image.ico"), Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PdfIsNotAPicture() {
|
||||
Assert.That(MediaHelpers.IsPicture(null, "notanimage.pdf"), Is.False);
|
||||
}
|
||||
}
|
||||
}
|
@@ -148,6 +148,7 @@
|
||||
<Compile Include="Indexing\IndexingTaskExecutorTests.cs" />
|
||||
<Compile Include="Indexing\LuceneIndexProviderTests.cs" />
|
||||
<Compile Include="Indexing\LuceneSearchBuilderTests.cs" />
|
||||
<Compile Include="Media\Extensions\MediaHelpersTests.cs" />
|
||||
<Compile Include="Media\Services\MediaServiceTests.cs" />
|
||||
<Compile Include="Packaging\Services\FileBasedProjectSystemTests.cs" />
|
||||
<Compile Include="Packaging\Services\FolderUpdaterTests.cs" />
|
||||
|
@@ -252,7 +252,7 @@ namespace Orchard.Media.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult EditMedia(MediaItemEditViewModel model) {
|
||||
model.PublicUrl = _mediaService.GetPublicUrl(Path.Combine(model.MediaPath, model.Name));
|
||||
model.PublicUrl = _mediaService.GetMediaPublicUrl(model.MediaPath, model.Name);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Media.Models;
|
||||
|
||||
namespace Orchard.Media.Helpers {
|
||||
@@ -24,5 +26,10 @@ namespace Orchard.Media.Helpers {
|
||||
|
||||
return navigations;
|
||||
}
|
||||
|
||||
public static bool IsPicture(this HtmlHelper htmlHelper, string path) {
|
||||
return new[] {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico"}
|
||||
.Contains((Path.GetExtension(path) ?? "").ToLowerInvariant());
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,5 +8,6 @@ namespace Orchard.Media.Models {
|
||||
public long Size { get; set; }
|
||||
public string FolderName { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public string MediaPath { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,14 @@ namespace Orchard.Media.Services {
|
||||
/// <returns>The public path relative to the application url.</returns>
|
||||
string GetPublicUrl(string relativePath);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the public URL for a media file.
|
||||
/// </summary>
|
||||
/// <param name="mediaPath">The relative path of the media folder containing the media.</param>
|
||||
/// <param name="fileName">The media file name.</param>
|
||||
/// <returns>The public URL for the media.</returns>
|
||||
string GetMediaPublicUrl(string mediaPath, string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the media folders within a given relative path.
|
||||
/// </summary>
|
||||
|
@@ -50,7 +50,17 @@ namespace Orchard.Media.Services {
|
||||
Argument.ThrowIfNullOrEmpty(relativePath, "relativePath");
|
||||
|
||||
return _storageProvider.GetPublicUrl(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the public URL for a media file.
|
||||
/// </summary>
|
||||
/// <param name="mediaPath">The relative path of the media folder containing the media.</param>
|
||||
/// <param name="fileName">The media file name.</param>
|
||||
/// <returns>The public URL for the media.</returns>
|
||||
public string GetMediaPublicUrl(string mediaPath, string fileName) {
|
||||
return GetPublicUrl(Path.Combine(mediaPath, fileName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the media folders within a given relative path.
|
||||
@@ -79,7 +89,8 @@ namespace Orchard.Media.Services {
|
||||
Size = file.GetSize(),
|
||||
LastUpdated = file.GetLastUpdated(),
|
||||
Type = file.GetFileType(),
|
||||
FolderName = relativePath
|
||||
FolderName = relativePath,
|
||||
MediaPath = GetMediaPublicUrl(relativePath, file.GetName())
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
|
@@ -9,4 +9,10 @@
|
||||
.previewImage {
|
||||
max-height:640px;
|
||||
max-width:640px;
|
||||
}
|
||||
.smallPreviewImage {
|
||||
max-height:64px;
|
||||
max-width:128px;
|
||||
float: left;
|
||||
margin-right: 16px;
|
||||
}
|
@@ -68,6 +68,9 @@
|
||||
size = mediaFile.Size,
|
||||
folderName = mediaFile.FolderName,
|
||||
mediaPath = Model.MediaPath })
|
||||
@if (Html.IsPicture(mediaFile.Name)) {
|
||||
<img src="@mediaFile.MediaPath" class="smallPreviewImage" alt="@mediaFile.Name"/>
|
||||
}
|
||||
</td>
|
||||
<td>@mediaFile.User</td>
|
||||
<td>@mediaFile.LastUpdated</td>
|
||||
|
@@ -5,6 +5,10 @@
|
||||
@{
|
||||
Style.Require("MediaAdmin");
|
||||
Layout.Title = T("Edit Media - {0}", Model.Name).ToString();
|
||||
var isPicture = Html.IsPicture(Model.Name);
|
||||
var embedHTML = isPicture ?
|
||||
"<img src=\"" + Model.PublicUrl + "\"/>" :
|
||||
"<a href=\"" + Model.PublicUrl + "\">" + Model.Name + "</a>";
|
||||
}
|
||||
|
||||
<div class="breadCrumbs">
|
||||
@@ -18,23 +22,27 @@
|
||||
|
||||
<div class="sections clearBoth">
|
||||
<div class="primary">
|
||||
<div>
|
||||
<img src="@Model.PublicUrl" class="previewImage"/>
|
||||
</div>
|
||||
|
||||
@if (isPicture) {
|
||||
<div>
|
||||
<img src="@Model.PublicUrl" class="previewImage"/>
|
||||
</div>
|
||||
}
|
||||
else {
|
||||
<a href="@Model.PublicUrl">@Model.Name</a>
|
||||
}
|
||||
@* todo: make these real (including markup) *@
|
||||
<div>
|
||||
@* <label>@T("Dimensions: <span>500 x 375 pixels</span>")</label> *@
|
||||
@* <label>@T("Dimensions: <span>500 x 375 pixels</span>")</label> *@
|
||||
|
||||
<label>@T("Size: <span>{0}</span>", Model.Size.ToFriendlySizeString())</label>
|
||||
<label>@T("Size: <span>{0}</span>", Model.Size.ToFriendlySizeString())</label>
|
||||
|
||||
<label>@T("Added on: <span>{0}</span>", Model.LastUpdated)</label>
|
||||
<label>@T("Added on: <span>{0}</span>", Model.LastUpdated)</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="embedPath">@T("Embed:")</label>
|
||||
<input id="embedPath" class="textMedium" name="embedPath" type="text" readonly="readonly" value="<img src="@Model.PublicUrl" @* width="500" height="375" *@ />" />
|
||||
<span class="hint">@T("Copy this html to add this image to your site.")</span>
|
||||
<input id="embedPath" class="textMedium" name="embedPath" type="text" readonly="readonly" value="@embedHTML" />
|
||||
<span class="hint">@T("Copy this html to add this media file to your site.")</span>
|
||||
</div>
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
|
Reference in New Issue
Block a user