Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed xcopy not working #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MetaMomentum.Core/Config/MetaMomentumConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class MetaMomentumConfig {
public string OGSiteName { get; set; } = null;
public string TwitterName { get; set; } = null;
public string FacebookAppId { get; set; } = null;
public string FallbackImageUrl { get; set; }
//public string CanonicalDomain { get; set; } = null;

#if NET5_0_OR_GREATER
Expand All @@ -23,6 +24,7 @@ internal MetaMomentumConfig(IConfiguration configuration) {
OGSiteName = configSection?.OGSiteName;
TwitterName = configSection?.TwitterName;
FacebookAppId = configSection?.FacebookAppId;
FallbackImageUrl = configSection?.FallbackImageUrl;
//CanonicalDomain = ValidateCanonicalDomain(configSection?.CanonicalDomain);
}
}
Expand All @@ -31,6 +33,7 @@ public MetaMomentumConfig() {
OGSiteName = ConfigurationManager.AppSettings[$"{Constants.Configuration.SectionName}.{Constants.Configuration.OGSiteName}"];
TwitterName = ConfigurationManager.AppSettings[$"{Constants.Configuration.SectionName}.{Constants.Configuration.TwitterName}"];
FacebookAppId = ConfigurationManager.AppSettings[$"{Constants.Configuration.SectionName}.{Constants.Configuration.FacebookId}"];
FallbackImageUrl = ConfigurationManager.AppSettings[$"{Constants.Configuration.SectionName}.{Constants.Configuration.FallbackImageUrl}"];
//CanonicalDomain = MetaMomentumConfig.ValidateCanonicalDomain(ConfigurationManager.AppSettings[$"{Constants.Configuration.SectionName}.{Constants.Configuration.CanonicalDomain}"]);
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion MetaMomentum.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ internal static class Configuration {
internal const string OGSiteName = "OGSiteName";
internal const string TwitterName = "TwitterName";
internal const string FacebookId = "FacebookId";
internal const string CanonicalDomain = "CanonicalDomain";
internal const string FallbackImageUrl = "FallbackImageUrl";
//internal const string CanonicalDomain = "CanonicalDomain";
}
}
}
32 changes: 32 additions & 0 deletions MetaMomentum.Core/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

using MetaMomentum.Config;


#if NET5_0_OR_GREATER
using Umbraco.Cms.Web.Common.Controllers;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Web.Common.Attributes;
#else
using Umbraco.Web.WebApi;
using Umbraco.Web.Mvc;
using System.Web.Http;
#endif


namespace MetaMomentum.Controllers {

[PluginController("MetaMomentum")]
public class SettingsController: UmbracoApiController {

private readonly MetaMomentumConfig _metaMomentumConfig;

public SettingsController(MetaMomentumConfig metaMomentumConfig) {
_metaMomentumConfig = metaMomentumConfig;
}

[HttpGet]
public string FallbackImage() {
return _metaMomentumConfig.FallbackImageUrl;
}
}
}
7 changes: 6 additions & 1 deletion MetaMomentum.Core/Models/MetaValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ public class MetaValues {
public string TwitterName { get; set; }

/// <summary>
/// This value can be set in the Web.Config under AppSettings.json under `MetaMomentum.TwitterName`. Make sure that you include the @ symbol
/// This value can be set in the Web.Config under AppSettings.json under `MetaMomentum.FacebookAppId`. Make sure that you include the @ symbol
/// </summary>
public string FacebookAppId { get; set; }

/// <summary>
/// This value can be set in the Web.Config under AppSettings.json under `MetaMomentum.FallbackImageUrl`. Make sure that you include the @ symbol
/// </summary>
public string FallbackImageUrl { get; set; }

[Obsolete("Please use ShareImageUrl instead")]
public IPublishedContent ShareImage { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ private MetaValues MapToMetaValue(object source, bool preview, IPublishedPropert
NoIndex = md.NoIndex,
OGSiteName = _metaMomentumConfig.OGSiteName,
TwitterName = _metaMomentumConfig.TwitterName,
FacebookAppId = _metaMomentumConfig.FacebookAppId
FacebookAppId = _metaMomentumConfig.FacebookAppId,
FallbackImageUrl = _metaMomentumConfig?.FallbackImageUrl
};

return retVal;
Expand Down
2 changes: 1 addition & 1 deletion MetaMomentum.UmbracoV10/MetaMomentum.UmbracoV10.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy $(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.* $(ProjectDir)App_Plugins\MetaMomentum\ /S /E /Y&#xD;&#xA;xcopy $(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.* $(ProjectDir)Views\Partials\MetaMomentum\ /S /E /Y" />
<Exec Command="xcopy &quot;$(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.*&quot; &quot;$(ProjectDir)App_Plugins\MetaMomentum\&quot; /S /E /Y&#xD;&#xA;xcopy &quot;$(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.*&quot; &quot;$(ProjectDir)Views\Partials\MetaMomentum\&quot; /S /E /Y" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions MetaMomentum.UmbracoV8/MetaMomentum.UmbracoV8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@
</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>xcopy $(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.* $(ProjectDir)App_Plugins\MetaMomentum\ /S /E /Y
xcopy $(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.* $(ProjectDir)Views\Partials\MetaMomentum\ /S /E /Y</PreBuildEvent>
<PreBuildEvent>xcopy "$(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.*" "$(ProjectDir)App_Plugins\MetaMomentum\" /S /E /Y
xcopy "$(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.*" "$(ProjectDir)Views\Partials\MetaMomentum\" /S /E /Y</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
2 changes: 1 addition & 1 deletion MetaMomentum.UmbracoV9/MetaMomentum.UmbracoV9.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
<RazorCompileOnBuild>false</RazorCompileOnBuild>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="xcopy $(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.* $(ProjectDir)App_Plugins\MetaMomentum\ /S /E /Y&#xD;&#xA;xcopy $(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.* $(ProjectDir)Views\Partials\MetaMomentum\ /S /E /Y" />
<Exec Command="xcopy &quot;$(SolutionDir)MetaMomentum\App_Plugins\MetaMomentum\*.*&quot; &quot;$(ProjectDir)App_Plugins\MetaMomentum\&quot; /S /E /Y&#xD;&#xA;xcopy &quot;$(SolutionDir)MetaMomentum\Views\Partials\MetaMomentum\*.*&quot; &quot;$(ProjectDir)Views\Partials\MetaMomentum\&quot; /S /E /Y" />
</Target>
</Project>
16 changes: 13 additions & 3 deletions MetaMomentum/App_Plugins/MetaMomentum/editorView.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module("umbraco")
.controller("DM.MetaMomentum",
function ($scope, $filter, editorState, contentEditingHelper, editorService, mediaHelper, entityResource, $interval) {
function ($scope, $filter, $http, editorState, contentEditingHelper, editorService, mediaHelper, entityResource, $interval) {
var shareImgUpdateInterval;

$scope.sharePreviewType = null;
Expand Down Expand Up @@ -215,7 +215,6 @@ angular.module("umbraco")
$scope.updateShareImage = function () {
$scope.model.value.shareImage = null;


//check if there is one already set.
if ($scope.model.value.share.imageUrl != null) {
$scope.model.value.shareImageUrl = $scope.model.value.share.imageUrl;
Expand Down Expand Up @@ -281,13 +280,24 @@ angular.module("umbraco")
$scope.model.value.shareImage = null; //Share image is not rellevant, so reset to null;

}
return $scope.model.value.shareImageUrl;
console.log($scope.model)
if ($scope.model.value.shareImageUrl != null) {
return $scope.model.value.shareImageUrl;
}
}
//break rootLoop;
}
}
}
}

if (!$scope.siteFallbackImage) {
$http.get('/Umbraco/MetaMomentum/Settings/FallbackImage').then(function successCallback(response) {
$scope.siteFallbackImage = response.data;
}, function errorCallback(response) {
console.log(`Error getting site fallback image: ${response}`)
});
}


//If we got this far, then we havent found an image
Expand Down
12 changes: 10 additions & 2 deletions MetaMomentum/App_Plugins/MetaMomentum/editorView.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
</label>
<!--<button type="button" class="btn-reset btn-link" style="float:right;" ng-click="toggleSocialPreview()">{{(showEditSocial)? "Hide Preview" : "Edit Preview"}}</button>-->
<uui-button type="button" look="default" color="default" class="btn-reset btn-link" style="float:right;" ng-click="toggleSocialPreview()" ng-attr-label="{{(showEditSocial)? "Hide Preview" : "Edit Preview"}}">{{(showEditSocial)? "Hide Preview" : "Edit Preview"}}</uui-button>

</div>
</div>

Expand Down Expand Up @@ -120,18 +121,21 @@
</uui-tab>
</uui-tab-group>

<uui-icon-registry-essential >
<uui-icon-registry-essential>
<uui-action-bar style="position:absolute;z-index:100;transform:translateX(5px) translateY(5px)">
<uui-button label="edit" look="secondary" color="default" ng-on-click="openSocialPreview()">
<uui-icon name="edit"></uui-icon> Edit
</uui-button>

</uui-action-bar>
</uui-icon-registry-essential>

<div ng-if="model.config.showSocialPreviewFacebook == 1 && sharePreviewType==='facebook'" style="width:527px;font-family:Helvetica, Arial, sans-serif;position:relative;">
<uui-tag ng-if="!model.value.share.imageUrl && model.value.shareImageUrl" style="position: absolute;right: 0;z-index:100;transform: translateX(-5px) translateY(5px);" size="s" slot="tag" look="primary" color="default">Fallback Image Field</uui-tag>
<uui-tag ng-if="!model.value.shareImageUrl && siteFallbackImage" style="position: absolute;right: 0;z-index:100;transform: translateX(-5px) translateY(5px);" size="s" slot="tag" look="primary" color="default">Site Fallback Image</uui-tag>
<img ng-if="model.value.shareImageUrl" ng-src="{{model.value.shareImageUrl}}?width=540&height=281&mode=crop"
style="border:1px solid #dddfe2;width:calc(100% - 2px);" />
<img ng-if="siteFallbackImage && !model.value.shareImageUrl" ng-src="{{siteFallbackImage}}?width=540&height=281&mode=crop"
style="border:1px solid #dddfe2;width:calc(100% - 2px);" />
<div style="border:1px solid #dddfe2;background-color:#e9ebee;padding:10px 12px;">
<div style="color:#606770;text-transform:uppercase; line-height:11px;font-size:12px">
{{searchHost}}
Expand All @@ -150,6 +154,8 @@

<img ng-if="model.value.shareImageUrl" ng-src="{{model.value.shareImageUrl}}?width=438&height=220&mode=crop"
style="border:1px solid #dddfe2;width:calc(100%);" />
<img ng-if="siteFallbackImage && !model.value.shareImageUrl" ng-src="{{siteFallbackImage}}?width=438&height=220&mode=crop"
style="border:1px solid #dddfe2;width:calc(100%);" />
<div style="padding:10px 12px;">

<div style="max-height:1.3em; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:700;margin:0 0 .15em;color:#000;" ng-bind-html="updateShareTitle()">
Expand All @@ -172,6 +178,8 @@

<img ng-if="model.value.shareImageUrl" ng-src="{{model.value.shareImageUrl}}?width=502&height=263&mode=crop"
style="border:1px solid #dddfe2;width:calc(100%);" />
<img ng-if="siteFallbackImage && !model.value.shareImageUrl" ng-src="{{siteFallbackImage}}?width=502&height=263&mode=crop"
style="border:1px solid #dddfe2;width:calc(100%);" />
<div style="padding: 8px 12px; background-color: #E7EAEC">

<div style="max-height:40px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;margin:0 0 .15em;color:rgba(0,0,0,0.9);" ng-bind-html="updateShareTitle()">
Expand Down
13 changes: 11 additions & 2 deletions MetaMomentum/Views/Partials/MetaMomentum/RenderMetaTags.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@

@*Twitter Card ratio is 2:1 https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image *@
@*<meta name="twitter:image" content="@(Model.ShareImage.Url(mode: UrlMode.Absolute))?width=1200&height=628&bgcolor=white">*@
<meta name="twitter:image" content="@Model.GetAbsoluteShareImageUrl(Context.Request)?width=1200&height=600&bgcolor=white">

<meta name="twitter:image" content="@Model.GetAbsoluteShareImageUrl(Context.Request)?width=1200&height=600&bgcolor=white">
}
else if (!string.IsNullOrEmpty(Model.FallbackImageUrl))
{
@* Meta(FB) require images at least 1200x630 https://developers.facebook.com/docs/sharing/webmasters/images/ *@
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image" content="@Model.FallbackImageUrl" />

@*Twitter Card ratio is 2:1 https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary-card-with-large-image *@
@*<meta name="twitter:image" content="@(Model.ShareImage.Url(mode: UrlMode.Absolute))?width=1200&height=628&bgcolor=white">*@
<meta name="twitter:image" content="@Model.FallbackImageUrl">
}

@if (Model.NoIndex)
Expand Down