mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-15 21:43:27 +08:00
Making it so when a content item is set as the home page it's only accessible as the home page and not at its path
- current implication for blogs is that if a blog is set as the home page its posts are then all rooted (e.g. if a blog at /blog is set as the home page then it's available at / and a post at, say, /my-post instead of /blog/my-post). There should maybe be a setting to alter the paths of the posts but (1) that's a pain at the moment, (2) hacking the URL by removing the post slug would result in a 404 instead of redirecting to /, the path of the blog - we don't handle redirects of that nature - and (3) the ability to root a blog in this manner *has* been requested by some. --HG-- branch : dev
This commit is contained in:
parent
2798850a38
commit
381f70d47c
@ -17,7 +17,10 @@ Scenario: I can create a new blog and blog post
|
||||
And I hit "Save"
|
||||
And I go to "my-blog"
|
||||
Then I should see "<h1[^>]*>.*?My Blog.*?</h1>"
|
||||
When I go to "admin/blogs/my-blog/posts/create"
|
||||
When I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
Then I should see "foo"
|
||||
When I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -34,7 +37,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
|
||||
| name | value |
|
||||
| Routable.Title | My Blog |
|
||||
And I hit "Save"
|
||||
And I go to "admin/blogs/my-blog/posts/create"
|
||||
And I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -43,7 +48,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
|
||||
And I go to "my-blog/my-post"
|
||||
Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
|
||||
And I should see "Hi there."
|
||||
When I go to "admin/blogs/my-blog/posts/create"
|
||||
When I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -52,7 +59,9 @@ Scenario: I can create a new blog with multiple blog posts each with the same ti
|
||||
And I go to "my-blog/my-post-2"
|
||||
Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
|
||||
And I should see "Hi there, again."
|
||||
When I go to "admin/blogs/my-blog/posts/create"
|
||||
When I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -72,7 +81,9 @@ Scenario: I can create a new blog and blog post and when I change the slug of th
|
||||
And I hit "Save"
|
||||
And I go to "my-blog"
|
||||
Then I should see "<h1[^>]*>.*?My Blog.*?</h1>"
|
||||
When I go to "admin/blogs/my-blog/posts/create"
|
||||
When I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -81,7 +92,8 @@ Scenario: I can create a new blog and blog post and when I change the slug of th
|
||||
And I go to "my-blog/my-post"
|
||||
Then I should see "<h1[^>]*>.*?My Post.*?</h1>"
|
||||
And I should see "Hi there."
|
||||
When I go to "admin/blogs/my-blog"
|
||||
When I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "Blog Properties"
|
||||
And I fill in
|
||||
| name | value |
|
||||
@ -100,7 +112,9 @@ Scenario: When viewing a blog the user agent is given an RSS feed of the blog's
|
||||
| name | value |
|
||||
| Routable.Title | My Blog |
|
||||
And I hit "Save"
|
||||
And I go to "admin/blogs/my-blog/posts/create"
|
||||
And I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -135,7 +149,9 @@ Scenario: The virtual path of my installation when not at the root is reflected
|
||||
| name | value |
|
||||
| Routable.Title | My Blog |
|
||||
And I hit "Save"
|
||||
And I go to "admin/blogs/my-blog/posts/create"
|
||||
And I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
Then I should see "<span>http\://localhost/OrchardLocal/my-blog/</span>"
|
||||
|
||||
Scenario: The virtual path of my installation when at the root is reflected in the URL example for the slug field when creating a blog or blog post
|
||||
@ -146,10 +162,12 @@ Scenario: The virtual path of my installation when at the root is reflected in t
|
||||
| name | value |
|
||||
| Routable.Title | My Blog |
|
||||
And I hit "Save"
|
||||
And I go to "admin/blogs/my-blog/posts/create"
|
||||
And I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
Then I should see "<span>http\://localhost/my-blog/</span>"
|
||||
|
||||
Scenario: I set my blog to be the content for the home page and the posts for the blog should still be at the blog path prefixed path
|
||||
Scenario: I set my blog to be the content for the home page and the posts for the blog be rooted to the app
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/blogs/create"
|
||||
And I fill in
|
||||
@ -157,7 +175,9 @@ Scenario: I set my blog to be the content for the home page and the posts for th
|
||||
| Routable.Title | My Blog |
|
||||
| Routable.PromoteToHomePage | true |
|
||||
And I hit "Save"
|
||||
And I go to "admin/blogs/my-blog/posts/create"
|
||||
And I go to "admin/blogs"
|
||||
And I follow "My Blog"
|
||||
And I follow "New Post"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Routable.Title | My Post |
|
||||
@ -168,5 +188,5 @@ Scenario: I set my blog to be the content for the home page and the posts for th
|
||||
Then I should see "<h1>My Blog</h1>"
|
||||
When I go to "/my-blog"
|
||||
Then the status should be 404 "Not Found"
|
||||
When I go to "/my-blog/my-post"
|
||||
When I go to "/my-post"
|
||||
Then I should see "<h1>My Post</h1>"
|
||||
|
294
src/Orchard.Specs/Blogs.feature.cs
generated
294
src/Orchard.Specs/Blogs.feature.cs
generated
@ -97,7 +97,13 @@ this.ScenarioSetup(scenarioInfo);
|
||||
#line 19
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
|
||||
#line 20
|
||||
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
testRunner.When("I go to \"admin/blogs\"");
|
||||
#line 21
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 22
|
||||
testRunner.Then("I should see \"foo\"");
|
||||
#line 23
|
||||
testRunner.When("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -108,15 +114,15 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table2.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there."});
|
||||
#line 21
|
||||
#line 24
|
||||
testRunner.And("I fill in", ((string)(null)), table2);
|
||||
#line 25
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 26
|
||||
testRunner.And("I go to \"my-blog/my-post\"");
|
||||
#line 27
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 28
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 29
|
||||
testRunner.And("I go to \"my-blog/my-post\"");
|
||||
#line 30
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 31
|
||||
testRunner.And("I should see \"Hi there.\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
@ -129,11 +135,11 @@ this.ScenarioSetup(scenarioInfo);
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog with multiple blog posts each with the same title and uni" +
|
||||
"que slugs are generated or given for said posts", ((string[])(null)));
|
||||
#line 30
|
||||
#line 33
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 31
|
||||
#line 34
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 32
|
||||
#line 35
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -142,12 +148,16 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table3.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 33
|
||||
testRunner.And("I fill in", ((string)(null)), table3);
|
||||
#line 36
|
||||
testRunner.And("I fill in", ((string)(null)), table3);
|
||||
#line 39
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 37
|
||||
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 40
|
||||
testRunner.And("I go to \"admin/blogs\"");
|
||||
#line 41
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 42
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -158,18 +168,22 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table4.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there."});
|
||||
#line 38
|
||||
testRunner.And("I fill in", ((string)(null)), table4);
|
||||
#line 42
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 43
|
||||
testRunner.And("I fill in", ((string)(null)), table4);
|
||||
#line 47
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 48
|
||||
testRunner.And("I go to \"my-blog/my-post\"");
|
||||
#line 44
|
||||
#line 49
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 45
|
||||
#line 50
|
||||
testRunner.And("I should see \"Hi there.\"");
|
||||
#line 46
|
||||
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 51
|
||||
testRunner.When("I go to \"admin/blogs\"");
|
||||
#line 52
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 53
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -180,18 +194,22 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table5.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there, again."});
|
||||
#line 47
|
||||
testRunner.And("I fill in", ((string)(null)), table5);
|
||||
#line 51
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 52
|
||||
testRunner.And("I go to \"my-blog/my-post-2\"");
|
||||
#line 53
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 54
|
||||
testRunner.And("I fill in", ((string)(null)), table5);
|
||||
#line 58
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 59
|
||||
testRunner.And("I go to \"my-blog/my-post-2\"");
|
||||
#line 60
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 61
|
||||
testRunner.And("I should see \"Hi there, again.\"");
|
||||
#line 55
|
||||
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 62
|
||||
testRunner.When("I go to \"admin/blogs\"");
|
||||
#line 63
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 64
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -205,15 +223,15 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table6.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Are you still there?"});
|
||||
#line 56
|
||||
#line 65
|
||||
testRunner.And("I fill in", ((string)(null)), table6);
|
||||
#line 61
|
||||
#line 70
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 62
|
||||
#line 71
|
||||
testRunner.And("I go to \"my-blog/my-post-3\"");
|
||||
#line 63
|
||||
#line 72
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 64
|
||||
#line 73
|
||||
testRunner.And("I should see \"Are you still there?\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
@ -226,11 +244,11 @@ this.ScenarioSetup(scenarioInfo);
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can create a new blog and blog post and when I change the slug of the blog the " +
|
||||
"path of the plog post is updated", ((string[])(null)));
|
||||
#line 66
|
||||
#line 75
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 67
|
||||
#line 76
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 68
|
||||
#line 77
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -239,16 +257,20 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table7.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 69
|
||||
#line 78
|
||||
testRunner.And("I fill in", ((string)(null)), table7);
|
||||
#line 72
|
||||
#line 81
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 73
|
||||
#line 82
|
||||
testRunner.And("I go to \"my-blog\"");
|
||||
#line 74
|
||||
#line 83
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
|
||||
#line 75
|
||||
testRunner.When("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 84
|
||||
testRunner.When("I go to \"admin/blogs\"");
|
||||
#line 85
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 86
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -259,19 +281,21 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table8.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there."});
|
||||
#line 76
|
||||
#line 87
|
||||
testRunner.And("I fill in", ((string)(null)), table8);
|
||||
#line 80
|
||||
#line 91
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 81
|
||||
#line 92
|
||||
testRunner.And("I go to \"my-blog/my-post\"");
|
||||
#line 82
|
||||
#line 93
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 83
|
||||
#line 94
|
||||
testRunner.And("I should see \"Hi there.\"");
|
||||
#line 84
|
||||
testRunner.When("I go to \"admin/blogs/my-blog\"");
|
||||
#line 85
|
||||
#line 95
|
||||
testRunner.When("I go to \"admin/blogs\"");
|
||||
#line 96
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 97
|
||||
testRunner.And("I follow \"Blog Properties\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -280,19 +304,19 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table9.AddRow(new string[] {
|
||||
"Routable.Slug",
|
||||
"my-other-blog"});
|
||||
#line 86
|
||||
#line 98
|
||||
testRunner.And("I fill in", ((string)(null)), table9);
|
||||
#line 89
|
||||
#line 101
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 90
|
||||
#line 102
|
||||
testRunner.And("I go to \"my-other-blog\"");
|
||||
#line 91
|
||||
#line 103
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Blog.*?</h1>\"");
|
||||
#line 92
|
||||
#line 104
|
||||
testRunner.When("I go to \"my-other-blog/my-post\"");
|
||||
#line 93
|
||||
#line 105
|
||||
testRunner.Then("I should see \"<h1[^>]*>.*?My Post.*?</h1>\"");
|
||||
#line 94
|
||||
#line 106
|
||||
testRunner.And("I should see \"Hi there.\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
@ -303,11 +327,11 @@ this.ScenarioSetup(scenarioInfo);
|
||||
public virtual void WhenViewingABlogTheUserAgentIsGivenAnRSSFeedOfTheBlogSPosts()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("When viewing a blog the user agent is given an RSS feed of the blog\'s posts", ((string[])(null)));
|
||||
#line 96
|
||||
#line 108
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 97
|
||||
#line 109
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 98
|
||||
#line 110
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -316,12 +340,16 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table10.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 99
|
||||
#line 111
|
||||
testRunner.And("I fill in", ((string)(null)), table10);
|
||||
#line 102
|
||||
#line 114
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 103
|
||||
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 115
|
||||
testRunner.And("I go to \"admin/blogs\"");
|
||||
#line 116
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 117
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -332,15 +360,15 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table11.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there."});
|
||||
#line 104
|
||||
#line 118
|
||||
testRunner.And("I fill in", ((string)(null)), table11);
|
||||
#line 108
|
||||
#line 122
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 109
|
||||
#line 123
|
||||
testRunner.And("I am redirected");
|
||||
#line 110
|
||||
#line 124
|
||||
testRunner.And("I go to \"my-blog/my-post\"");
|
||||
#line 111
|
||||
#line 125
|
||||
testRunner.Then("I should see \"<link rel=\"alternate\" type=\"application/rss\\+xml\" title=\"My Blog\" h" +
|
||||
"ref=\"/rss\\?containerid=\\d+\" />\"");
|
||||
#line hidden
|
||||
@ -354,15 +382,15 @@ this.ScenarioSetup(scenarioInfo);
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Enabling remote blog publishing inserts the appropriate metaweblogapi markup into" +
|
||||
" the blog\'s page", ((string[])(null)));
|
||||
#line 114
|
||||
#line 128
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 115
|
||||
#line 129
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 116
|
||||
#line 130
|
||||
testRunner.And("I have enabled \"XmlRpc\"");
|
||||
#line 117
|
||||
#line 131
|
||||
testRunner.And("I have enabled \"Orchard.Blogs.RemotePublishing\"");
|
||||
#line 118
|
||||
#line 132
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -371,23 +399,23 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table12.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 119
|
||||
#line 133
|
||||
testRunner.And("I fill in", ((string)(null)), table12);
|
||||
#line 122
|
||||
#line 136
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 123
|
||||
#line 137
|
||||
testRunner.And("I go to \"my-blog\"");
|
||||
#line 124
|
||||
#line 138
|
||||
testRunner.Then("I should see \"<link href=\"[^\"]*/XmlRpc/LiveWriter/Manifest\" rel=\"wlwmanifest\" typ" +
|
||||
"e=\"application/wlwmanifest\\+xml\" />\"");
|
||||
#line 125
|
||||
#line 139
|
||||
testRunner.When("I go to \"/XmlRpc/LiveWriter/Manifest\"");
|
||||
#line 126
|
||||
#line 140
|
||||
testRunner.Then("the content type should be \"\\btext/xml\\b\"");
|
||||
#line 127
|
||||
#line 141
|
||||
testRunner.And("I should see \"<manifest xmlns=\"http\\://schemas\\.microsoft\\.com/wlw/manifest/weblo" +
|
||||
"g\">\"");
|
||||
#line 128
|
||||
#line 142
|
||||
testRunner.And("I should see \"<clientType>Metaweblog</clientType>\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
@ -400,13 +428,13 @@ this.ScenarioSetup(scenarioInfo);
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when not at the root is reflected in the URL " +
|
||||
"example for the slug field when creating a blog or blog post", ((string[])(null)));
|
||||
#line 130
|
||||
#line 144
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 131
|
||||
#line 145
|
||||
testRunner.Given("I have installed Orchard at \"/OrchardLocal\"");
|
||||
#line 132
|
||||
#line 146
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line 133
|
||||
#line 147
|
||||
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/</span>\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -415,13 +443,17 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table13.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 134
|
||||
#line 148
|
||||
testRunner.When("I fill in", ((string)(null)), table13);
|
||||
#line 137
|
||||
#line 151
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 138
|
||||
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 139
|
||||
#line 152
|
||||
testRunner.And("I go to \"admin/blogs\"");
|
||||
#line 153
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 154
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line 155
|
||||
testRunner.Then("I should see \"<span>http\\://localhost/OrchardLocal/my-blog/</span>\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
@ -434,13 +466,13 @@ this.ScenarioSetup(scenarioInfo);
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("The virtual path of my installation when at the root is reflected in the URL exam" +
|
||||
"ple for the slug field when creating a blog or blog post", ((string[])(null)));
|
||||
#line 141
|
||||
#line 157
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 142
|
||||
#line 158
|
||||
testRunner.Given("I have installed Orchard at \"/\"");
|
||||
#line 143
|
||||
#line 159
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line 144
|
||||
#line 160
|
||||
testRunner.Then("I should see \"<span>http\\://localhost/</span>\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -449,30 +481,34 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table14.AddRow(new string[] {
|
||||
"Routable.Title",
|
||||
"My Blog"});
|
||||
#line 145
|
||||
#line 161
|
||||
testRunner.When("I fill in", ((string)(null)), table14);
|
||||
#line 148
|
||||
#line 164
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 149
|
||||
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 150
|
||||
#line 165
|
||||
testRunner.And("I go to \"admin/blogs\"");
|
||||
#line 166
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 167
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line 168
|
||||
testRunner.Then("I should see \"<span>http\\://localhost/my-blog/</span>\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
}
|
||||
|
||||
[NUnit.Framework.TestAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("I set my blog to be the content for the home page and the posts for the blog shou" +
|
||||
"ld still be at the blog path prefixed path")]
|
||||
public virtual void ISetMyBlogToBeTheContentForTheHomePageAndThePostsForTheBlogShouldStillBeAtTheBlogPathPrefixedPath()
|
||||
[NUnit.Framework.DescriptionAttribute("I set my blog to be the content for the home page and the posts for the blog be r" +
|
||||
"ooted to the app")]
|
||||
public virtual void ISetMyBlogToBeTheContentForTheHomePageAndThePostsForTheBlogBeRootedToTheApp()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I set my blog to be the content for the home page and the posts for the blog shou" +
|
||||
"ld still be at the blog path prefixed path", ((string[])(null)));
|
||||
#line 152
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I set my blog to be the content for the home page and the posts for the blog be r" +
|
||||
"ooted to the app", ((string[])(null)));
|
||||
#line 170
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 153
|
||||
#line 171
|
||||
testRunner.Given("I have installed Orchard");
|
||||
#line 154
|
||||
#line 172
|
||||
testRunner.When("I go to \"admin/blogs/create\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
@ -484,12 +520,16 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table15.AddRow(new string[] {
|
||||
"Routable.PromoteToHomePage",
|
||||
"true"});
|
||||
#line 155
|
||||
#line 173
|
||||
testRunner.And("I fill in", ((string)(null)), table15);
|
||||
#line 159
|
||||
#line 177
|
||||
testRunner.And("I hit \"Save\"");
|
||||
#line 160
|
||||
testRunner.And("I go to \"admin/blogs/my-blog/posts/create\"");
|
||||
#line 178
|
||||
testRunner.And("I go to \"admin/blogs\"");
|
||||
#line 179
|
||||
testRunner.And("I follow \"My Blog\"");
|
||||
#line 180
|
||||
testRunner.And("I follow \"New Post\"");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
@ -500,23 +540,23 @@ this.ScenarioSetup(scenarioInfo);
|
||||
table16.AddRow(new string[] {
|
||||
"Body.Text",
|
||||
"Hi there."});
|
||||
#line 161
|
||||
#line 181
|
||||
testRunner.And("I fill in", ((string)(null)), table16);
|
||||
#line 165
|
||||
#line 185
|
||||
testRunner.And("I hit \"Publish Now\"");
|
||||
#line 166
|
||||
#line 186
|
||||
testRunner.And("I am redirected");
|
||||
#line 167
|
||||
#line 187
|
||||
testRunner.And("I go to \"/Default.aspx\"");
|
||||
#line 168
|
||||
#line 188
|
||||
testRunner.Then("I should see \"<h1>My Blog</h1>\"");
|
||||
#line 169
|
||||
#line 189
|
||||
testRunner.When("I go to \"/my-blog\"");
|
||||
#line 170
|
||||
#line 190
|
||||
testRunner.Then("the status should be 404 \"Not Found\"");
|
||||
#line 171
|
||||
testRunner.When("I go to \"/my-blog/my-post\"");
|
||||
#line 172
|
||||
#line 191
|
||||
testRunner.When("I go to \"/my-post\"");
|
||||
#line 192
|
||||
testRunner.Then("I should see \"<h1>My Post</h1>\"");
|
||||
#line hidden
|
||||
testRunner.CollectScenarioErrors();
|
||||
|
@ -41,7 +41,7 @@ Scenario: If I create a page which gets a conflicting path generated its path is
|
||||
Then I should see "<h1[^>]*>.*?Super Duper.*?</h1>"
|
||||
And I should see "This is super number two."
|
||||
|
||||
Scenario: A new page marked to be the home page and publish does take over the home page and is not accessible from its own standard path.
|
||||
Scenario: A new page marked to be the home page and publish does take over the home page and is not accessible from its own standard path
|
||||
Given I have installed Orchard
|
||||
When I go to "admin/contents/create/page"
|
||||
And I fill in
|
||||
|
6
src/Orchard.Specs/Pages.feature.cs
generated
6
src/Orchard.Specs/Pages.feature.cs
generated
@ -166,11 +166,11 @@ this.ScenarioSetup(scenarioInfo);
|
||||
|
||||
[NUnit.Framework.TestAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("A new page marked to be the home page and publish does take over the home page an" +
|
||||
"d is not accessible from its own standard path.")]
|
||||
public virtual void ANewPageMarkedToBeTheHomePageAndPublishDoesTakeOverTheHomePageAndIsNotAccessibleFromItsOwnStandardPath_()
|
||||
"d is not accessible from its own standard path")]
|
||||
public virtual void ANewPageMarkedToBeTheHomePageAndPublishDoesTakeOverTheHomePageAndIsNotAccessibleFromItsOwnStandardPath()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("A new page marked to be the home page and publish does take over the home page an" +
|
||||
"d is not accessible from its own standard path.", ((string[])(null)));
|
||||
"d is not accessible from its own standard path", ((string[])(null)));
|
||||
#line 44
|
||||
this.ScenarioSetup(scenarioInfo);
|
||||
#line 45
|
||||
|
@ -58,14 +58,7 @@ namespace Orchard.Core.Routable.Controllers {
|
||||
throw new ApplicationException(T("Ambiguous content").Text);
|
||||
}
|
||||
|
||||
var item = hits.Single();
|
||||
// primary action run for a home paged item shall not pass
|
||||
if (!RouteData.DataTokens.ContainsKey("ParentActionViewContext")
|
||||
&& item.Id == _routableHomePageProvider.GetHomePageId(_workContextAccessor.GetContext().CurrentSite.HomePage)) {
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
dynamic model = _contentManager.BuildDisplay(item);
|
||||
dynamic model = _contentManager.BuildDisplay(hits.Single());
|
||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||
return View((object)model);
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
private readonly IOrchardServices _services;
|
||||
private readonly IRoutablePathConstraint _routablePathConstraint;
|
||||
private readonly IRoutableService _routableService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IHomePageProvider _routableHomePageProvider;
|
||||
|
||||
public RoutePartHandler(
|
||||
@ -23,11 +25,14 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
IRepository<RoutePartRecord> repository,
|
||||
IRoutablePathConstraint routablePathConstraint,
|
||||
IRoutableService routableService,
|
||||
IContentManager contentManager,
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
IEnumerable<IHomePageProvider> homePageProviders) {
|
||||
_services = services;
|
||||
_routablePathConstraint = routablePathConstraint;
|
||||
_routableService = routableService;
|
||||
_contentManager = contentManager;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
|
||||
T = NullLocalizer.Instance;
|
||||
|
||||
@ -47,9 +52,26 @@ namespace Orchard.Core.Routable.Handlers {
|
||||
OnPublished<RoutePart>((context, route) => {
|
||||
FinalizePath(route, context, processSlug);
|
||||
|
||||
if (route.ContentItem.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null) {
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
|
||||
_routablePathConstraint.AddPath("");
|
||||
if (route.Id != 0 && route.PromoteToHomePage && _routableHomePageProvider != null) {
|
||||
var homePageSetting = _workContextAccessor.GetContext().CurrentSite.HomePage;
|
||||
var currentHomePageId = !string.IsNullOrWhiteSpace(homePageSetting)
|
||||
? _routableHomePageProvider.GetHomePageId(homePageSetting)
|
||||
: 0;
|
||||
|
||||
if (currentHomePageId != route.Id) {
|
||||
// reset the path on the current home page
|
||||
var currentHomePage = _contentManager.Get(currentHomePageId);
|
||||
if (currentHomePage != null)
|
||||
FinalizePath(currentHomePage.As<RoutePart>(), context, processSlug);
|
||||
// set the new home page
|
||||
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(route.ContentItem.Id);
|
||||
}
|
||||
|
||||
// readjust the constraints of the current current home page
|
||||
_routablePathConstraint.RemovePath(route.Path);
|
||||
route.Path = "";
|
||||
_routableService.FixContainedPaths(route);
|
||||
_routablePathConstraint.AddPath(route.Path);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System.Linq;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
@ -32,12 +30,12 @@ namespace Orchard.Blogs {
|
||||
}
|
||||
else if (singleBlog != null)
|
||||
menu.Add(T("Manage Blog"), "1.0",
|
||||
item => item.Action("Item", "BlogAdmin", new { area = "Orchard.Blogs", blogSlug = singleBlog.As<IRoutableAspect>().Path }).Permission(Permissions.MetaListBlogs));
|
||||
item => item.Action("Item", "BlogAdmin", new { area = "Orchard.Blogs", blogId = singleBlog.Id }).Permission(Permissions.MetaListBlogs));
|
||||
|
||||
if (singleBlog != null)
|
||||
menu.Add(T("Create New Post"), "1.1",
|
||||
item =>
|
||||
item.Action("Create", "BlogPostAdmin", new { area = "Orchard.Blogs", blogSlug = singleBlog.As<IRoutableAspect>().Path }).Permission(Permissions.PublishBlogPost));
|
||||
item.Action("Create", "BlogPostAdmin", new { area = "Orchard.Blogs", blogId = singleBlog.Id }).Permission(Permissions.PublishBlogPost));
|
||||
|
||||
menu.Add(T("Create New Blog"), "1.2",
|
||||
item =>
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Blogs.Models;
|
||||
@ -50,7 +49,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to create blogs")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
BlogPart blog = Services.ContentManager.New<BlogPart>("Blog");
|
||||
var blog = Services.ContentManager.New<BlogPart>("Blog");
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -81,11 +80,11 @@ namespace Orchard.Blogs.Controllers {
|
||||
return Redirect(Url.BlogForAdmin(blog));
|
||||
}
|
||||
|
||||
public ActionResult Edit(int id) {
|
||||
public ActionResult Edit(int blogId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Not allowed to edit blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(id, VersionOptions.Latest);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -95,11 +94,11 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
public ActionResult EditPOST(int id) {
|
||||
public ActionResult EditPOST(int blogId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't edit blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(id, VersionOptions.DraftRequired);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.DraftRequired);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -118,11 +117,11 @@ namespace Orchard.Blogs.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Remove(int id) {
|
||||
public ActionResult Remove(int blogId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageBlogs, T("Couldn't delete blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(id, VersionOptions.Latest);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
@ -148,8 +147,8 @@ namespace Orchard.Blogs.Controllers {
|
||||
return View((object)viewModel);
|
||||
}
|
||||
|
||||
public ActionResult Item(string blogSlug, Pager pager) {
|
||||
BlogPart blogPart = _blogService.Get(blogSlug);
|
||||
public ActionResult Item(int blogId, Pager pager) {
|
||||
BlogPart blogPart = _blogService.Get(blogId, VersionOptions.Latest).As<BlogPart>();
|
||||
|
||||
if (blogPart == null)
|
||||
return HttpNotFound();
|
||||
|
@ -80,11 +80,11 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
//todo: the content shape template has extra bits that the core contents module does not (remove draft functionality)
|
||||
//todo: - move this extra functionality there or somewhere else that's appropriate?
|
||||
public ActionResult Edit(string blogSlug, int postId) {
|
||||
public ActionResult Edit(int blogId, int postId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogSlug);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -99,8 +99,8 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Save")]
|
||||
public ActionResult EditPOST(string blogSlug, int postId, string returnUrl) {
|
||||
return EditPOST(blogSlug, postId, returnUrl, contentItem => {
|
||||
public ActionResult EditPOST(int blogId, int postId, string returnUrl) {
|
||||
return EditPOST(blogId, postId, returnUrl, contentItem => {
|
||||
if (!contentItem.Has<IPublishingControlAspect>() && !contentItem.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
|
||||
Services.ContentManager.Publish(contentItem);
|
||||
});
|
||||
@ -108,15 +108,15 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Edit")]
|
||||
[FormValueRequired("submit.Publish")]
|
||||
public ActionResult EditAndPublishPOST(string blogSlug, int postId, string returnUrl) {
|
||||
return EditPOST(blogSlug, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
|
||||
public ActionResult EditAndPublishPOST(int blogId, int postId, string returnUrl) {
|
||||
return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
|
||||
}
|
||||
|
||||
public ActionResult EditPOST(string blogSlug, int postId, string returnUrl, Action<ContentItem> conditionallyPublish) {
|
||||
public ActionResult EditPOST(int blogId, int postId, string returnUrl, Action<ContentItem> conditionallyPublish) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, T("Couldn't edit blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogSlug);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -178,16 +178,16 @@ namespace Orchard.Blogs.Controllers {
|
||||
ActionResult RedirectToEdit(IContent item) {
|
||||
if (item == null || item.As<BlogPostPart>() == null)
|
||||
return HttpNotFound();
|
||||
return RedirectToAction("Edit", new { BlogSlug = item.As<IRoutableAspect>().Path, PostId = item.ContentItem.Id });
|
||||
return RedirectToAction("Edit", new { BlogId = item.As<BlogPostPart>().BlogPart.Id, PostId = item.ContentItem.Id });
|
||||
}
|
||||
|
||||
[ValidateAntiForgeryTokenOrchard]
|
||||
public ActionResult Delete(string blogSlug, int postId) {
|
||||
public ActionResult Delete(int blogId, int postId) {
|
||||
//refactoring: test PublishBlogPost/PublishOthersBlogPost in addition if published
|
||||
if (!Services.Authorizer.Authorize(Permissions.DeleteBlogPost, T("Couldn't delete blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogSlug);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -198,15 +198,15 @@ namespace Orchard.Blogs.Controllers {
|
||||
_blogPostService.Delete(post);
|
||||
Services.Notifier.Information(T("Blog post was successfully deleted"));
|
||||
|
||||
return Redirect(Url.BlogForAdmin(blog));
|
||||
return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
|
||||
}
|
||||
|
||||
[ValidateAntiForgeryTokenOrchard]
|
||||
public ActionResult Publish(string blogSlug, int postId) {
|
||||
public ActionResult Publish(int blogId, int postId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't publish blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogSlug);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -217,15 +217,15 @@ namespace Orchard.Blogs.Controllers {
|
||||
_blogPostService.Publish(post);
|
||||
Services.Notifier.Information(T("Blog post successfully published."));
|
||||
|
||||
return Redirect(Url.BlogForAdmin(blog));
|
||||
return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
|
||||
}
|
||||
|
||||
[ValidateAntiForgeryTokenOrchard]
|
||||
public ActionResult Unpublish(string blogSlug, int postId) {
|
||||
public ActionResult Unpublish(int blogId, int postId) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, T("Couldn't unpublish blog post")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var blog = _blogService.Get(blogSlug);
|
||||
var blog = _blogService.Get(blogId, VersionOptions.Latest);
|
||||
if (blog == null)
|
||||
return HttpNotFound();
|
||||
|
||||
@ -236,7 +236,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
_blogPostService.Unpublish(post);
|
||||
Services.Notifier.Information(T("Blog post successfully unpublished."));
|
||||
|
||||
return Redirect(Url.BlogForAdmin(blog));
|
||||
return Redirect(Url.BlogForAdmin(blog.As<BlogPart>()));
|
||||
}
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
|
@ -40,23 +40,23 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
public static string BlogForAdmin(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.Action("Item", "BlogAdmin", new { blogSlug = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Item", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogCreate(this UrlHelper urlHelper) {
|
||||
return urlHelper.Action("Create", "BlogAdmin", new {area = "Orchard.Blogs"});
|
||||
return urlHelper.Action("Create", "BlogAdmin", new { area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogEdit(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.Action("Edit", "BlogAdmin", new { blogPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Edit", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogRemove(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.Action("Remove", "BlogAdmin", new { blogPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Remove", "BlogAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPostCreate(this UrlHelper urlHelper, BlogPart blogPart) {
|
||||
return urlHelper.Action("Create", "BlogPostAdmin", new { blogSlug = blogPart.As<IRoutableAspect>().Path, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Create", "BlogPostAdmin", new { blogId = blogPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPost(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
@ -64,19 +64,19 @@ namespace Orchard.Blogs.Extensions {
|
||||
}
|
||||
|
||||
public static string BlogPostEdit(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
return urlHelper.Action("Edit", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Edit", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPostDelete(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
return urlHelper.Action("Delete", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Delete", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPostPublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Publish", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
|
||||
public static string BlogPostUnpublish(this UrlHelper urlHelper, BlogPostPart blogPostPart) {
|
||||
return urlHelper.Action("Unpublish", "BlogPostAdmin", new { blogSlug = blogPostPart.BlogPart.As<IRoutableAspect>().Path, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
return urlHelper.Action("Unpublish", "BlogPostAdmin", new { blogId = blogPostPart.BlogPart.Id, postId = blogPostPart.Id, area = "Orchard.Blogs" });
|
||||
}
|
||||
}
|
||||
}
|
@ -65,13 +65,13 @@ namespace Orchard.Blogs.Handlers {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
{"Controller", "BlogAdmin"},
|
||||
{"Action", "Edit"},
|
||||
{"Id", context.ContentItem.Id}
|
||||
{"blogId", context.ContentItem.Id}
|
||||
};
|
||||
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
{"Controller", "BlogAdmin"},
|
||||
{"Action", "Remove"},
|
||||
{"Id", context.ContentItem.Id}
|
||||
{"blogId", context.ContentItem.Id}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,10 @@ namespace Orchard.Blogs.Handlers {
|
||||
OnUpdateEditorShape<BlogPostPart>(SetModelProperties);
|
||||
|
||||
OnInitializing<BlogPostPart>((context, bp) => {
|
||||
var blogSlug = requestContext.RouteData.Values.ContainsKey("blogSlug") ? requestContext.RouteData.Values["blogSlug"] as string : null;
|
||||
if (!string.IsNullOrEmpty(blogSlug)) {
|
||||
bp.BlogPart = blogService.Get(blogSlug);
|
||||
var blogId = requestContext.RouteData.Values.ContainsKey("blogId") ? requestContext.RouteData.Values["blogId"] as string : null;
|
||||
if (!string.IsNullOrEmpty(blogId)) {
|
||||
var blog = blogService.Get(int.Parse(blogId), VersionOptions.Latest);
|
||||
bp.BlogPart = blog.As<BlogPart>();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -72,14 +73,14 @@ namespace Orchard.Blogs.Handlers {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
{"Controller", "BlogPostAdmin"},
|
||||
{"Action", "Create"},
|
||||
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug}
|
||||
{"blogId", blogPost.BlogPart.Id}
|
||||
};
|
||||
context.Metadata.EditorRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
{"Controller", "BlogPostAdmin"},
|
||||
{"Action", "Edit"},
|
||||
{"postId", context.ContentItem.Id},
|
||||
{"blogSlug", blogPost.BlogPart.As<RoutePart>().Slug}
|
||||
{"blogId", blogPost.BlogPart.Id}
|
||||
};
|
||||
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
|
||||
{"Area", "Orchard.Blogs"},
|
||||
|
@ -35,7 +35,7 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{id}/Edit",
|
||||
"Admin/Blogs/{blogId}/Edit",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogAdmin"},
|
||||
@ -49,7 +49,7 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{id}/Remove",
|
||||
"Admin/Blogs/{blogId}/Remove",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogAdmin"},
|
||||
@ -63,15 +63,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}",
|
||||
"Admin/Blogs/{blogId}",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogAdmin"},
|
||||
{"action", "Item"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
@ -79,15 +77,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}/Posts/Create",
|
||||
"Admin/Blogs/{blogId}/Posts/Create",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPostAdmin"},
|
||||
{"action", "Create"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
@ -95,15 +91,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}/Posts/{postId}/Edit",
|
||||
"Admin/Blogs/{blogId}/Posts/{postId}/Edit",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPostAdmin"},
|
||||
{"action", "Edit"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
@ -111,15 +105,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}/Posts/{postId}/Delete",
|
||||
"Admin/Blogs/{blogId}/Posts/{postId}/Delete",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPostAdmin"},
|
||||
{"action", "Delete"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
@ -127,15 +119,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}/Posts/{postId}/Publish",
|
||||
"Admin/Blogs/{blogId}/Posts/{postId}/Publish",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPostAdmin"},
|
||||
{"action", "Publish"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
@ -143,15 +133,13 @@ namespace Orchard.Blogs {
|
||||
},
|
||||
new RouteDescriptor {
|
||||
Route = new Route(
|
||||
"Admin/Blogs/{blogSlug}/Posts/{postId}/Unpublish",
|
||||
"Admin/Blogs/{blogId}/Posts/{postId}/Unpublish",
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"},
|
||||
{"controller", "BlogPostAdmin"},
|
||||
{"action", "Unpublish"}
|
||||
},
|
||||
new RouteValueDictionary {
|
||||
{"blogSlug", _blogSlugConstraint}
|
||||
},
|
||||
new RouteValueDictionary (),
|
||||
new RouteValueDictionary {
|
||||
{"area", "Orchard.Blogs"}
|
||||
},
|
||||
|
@ -281,8 +281,9 @@ namespace Orchard.Setup.Services {
|
||||
// create a welcome page that's promoted to the home page
|
||||
var page = contentManager.Create("Page", VersionOptions.Draft);
|
||||
page.As<RoutePart>().Title = T("Welcome to Orchard!").Text;
|
||||
page.As<RoutePart>().Path = "";
|
||||
page.As<RoutePart>().Slug = "";
|
||||
page.As<RoutePart>().Path = "welcome-to-orchard";
|
||||
page.As<RoutePart>().Slug = "welcome-to-orchard";
|
||||
page.As<RoutePart>().PromoteToHomePage = true;
|
||||
page.As<BodyPart>().Text = T(
|
||||
@"<p>You've successfully setup your Orchard Site and this is the homepage of your new site.
|
||||
Here are a few things you can look at to get familiar with the application.
|
||||
@ -304,7 +305,6 @@ Modules are created by other users of Orchard just like you so if you feel up to
|
||||
<p>Thanks for using Orchard – The Orchard Team </p>", page.Id).Text;
|
||||
|
||||
contentManager.Publish(page);
|
||||
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;
|
||||
|
||||
// add a menu item for the shiny new home page
|
||||
var menuItem = contentManager.Create("MenuItem");
|
||||
|
Loading…
Reference in New Issue
Block a user