Skip to content

Commit

Permalink
Remove Try .NET from web site
Browse files Browse the repository at this point in the history
Closes #100

We don't have the time to get this working again, really.
  • Loading branch information
jskeet committed Nov 7, 2024
1 parent 00a7530 commit f749995
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 230 deletions.
18 changes: 0 additions & 18 deletions src/NodaTime.Web/Configuration/TryDotNetOptions.cs

This file was deleted.

6 changes: 2 additions & 4 deletions src/NodaTime.Web/Controllers/DocumentationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ namespace NodaTime.Web.Controllers
public class DocumentationController : Controller
{
private readonly MarkdownLoader loader;
private readonly TryDotNetOptions tryDotNetOptions;

public DocumentationController(MarkdownLoader loader, TryDotNetOptions tryDotNetOptions)
public DocumentationController(MarkdownLoader loader)
{
this.loader = loader;
this.tryDotNetOptions = tryDotNetOptions;
}

public IActionResult ViewDocumentation(string bundle, string url)
Expand All @@ -29,7 +27,7 @@ public IActionResult ViewDocumentation(string bundle, string url)
var page = loader.TryGetBundle(bundle)?.TryGetPage(url);
if (page != null)
{
return View("Docs", new MarkdownPageViewModel(tryDotNetOptions.IFrameSrc, origin, page));
return View("Docs", new MarkdownPageViewModel(origin, page));
}
var resource = loader.TryGetBundle(bundle)?.TryGetResource(url);
if (resource != null)
Expand Down
30 changes: 4 additions & 26 deletions src/NodaTime.Web/Markdown/2.0.x/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,13 @@ These examples typically use explicitly-typed local variables so that you can te
all the types involved easily. You can use implicitly-typed local variables (`var`)
in your own code, of course.

Try it live!
====

To run any recipe immediately, just hit the "Copy to editor" button and then the "Run" button.
You can then modify the code - including using Intellisense to explore the API, by pressing Ctrl-Space -
and rerun it to see the results.

<div style="height:250px; padding:8px 0px">
<iframe style="position:relative;top:0px;width:100%;height:100%"
id="trydotnet-editor"></iframe>
</div>
<div><button id="trydotnet-run" class="trydotnetbutton">Run!</button></div>
<div>
<p class="trydotnet-outputlabel">Output:</p>
<pre><code id="trydotnet-output"></code></pre>
</div>
<div class="trydotnetbanner">
<p>Powered by <a href="https://github.com/dotnet/try/wiki">Try .NET</a> currently in select preview</p>
</div>

How old is Jon?
====

Jon was born on June 19th, 1976 (Gregorian). How old is he now, in the UK time zone?

```csharp-trydotnet
```csharp
LocalDate birthDate = new LocalDate(1976, 6, 19);
DateTimeZone zone = DateTimeZoneProviders.Tzdb["Europe/London"];
ZonedClock clock = SystemClock.Instance.InZone(zone);
Expand All @@ -48,25 +29,22 @@ Console.WriteLine(
Note that a `using` directive for `NodaTime.Extensions` is required for this,
as `InZone` is an extension method in `NodaTime.Extensions.ClockExtensions`.

(Also note that running this recipe in Try .NET may show an old date, if the
result is cached from a previous run. We're working on it!)

How can I get to the start or end of a month?
====

Use the [`DateAdjusters`](noda-type://NodaTime.DateAdjusters) factory class to obtain a suitable adjuster, and then either apply it
directly (it's just a `Func<LocalDate, LocalDate>`) or use the `With` method to apply it in a fluent
style:

```csharp-trydotnet
```csharp
LocalDate today = new LocalDate(2014, 6, 27);
LocalDate endOfMonth = today.With(DateAdjusters.EndOfMonth);
Console.WriteLine(endOfMonth); // 2014-06-30
```

Date adjusters also work with `LocalDateTime` and `OffsetDateTime` values. For example:

```csharp-trydotnet
```csharp
LocalDateTime now = new LocalDateTime(2014, 6, 27, 7, 14, 25);
LocalDateTime startOfMonth = now.With(DateAdjusters.StartOfMonth);
Console.WriteLine(startOfMonth); // 2014-06-01T07:14:25
Expand All @@ -78,7 +56,7 @@ How can I truncate a time to a particular unit?
Use the [`TimeAdjusters`](noda-type://NodaTime.TimeAdjusters) factory class to obtain a suitable adjuster, which can be applied to a
`LocalTime`, `LocalDateTime` or `OffsetDateTime`:

```csharp-trydotnet
```csharp
LocalDateTime now = new LocalDateTime(2014, 6, 27, 7, 14, 25, 500);
LocalDateTime truncated = now.With(TimeAdjusters.TruncateToMinute); // 2014-06-27T07:14:00
```
1 change: 0 additions & 1 deletion src/NodaTime.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void ConfigureServices(IServiceCollection services)
var storageOptions = Configuration.GetSection("Storage").Get<StorageOptions>() ?? throw new ArgumentException("Must have storage options");
storageOptions.ConfigureServices(services);
services.AddHttpClient();
services.AddSingleton(Configuration.GetSection("TryDotNet").Get<TryDotNetOptions>() ?? throw new ArgumentException("Must specify TryDotNet options"));
services.AddSingleton<MarkdownLoader>();
services.AddMemoryCache();
}
Expand Down
6 changes: 2 additions & 4 deletions src/NodaTime.Web/ViewModels/MarkdownPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
// Use of this source code is governed by the Apache License 2.0,
// as found in the LICENSE.txt file.

using Microsoft.AspNetCore.Html;
using NodaTime.Web.Models;

namespace NodaTime.Web.ViewModels
{
public class MarkdownPageViewModel
{
public IHtmlContent TryDotNetSrc { get; }
public string HostOrigin { get; }
public MarkdownPage Page { get; }

public MarkdownPageViewModel(IHtmlContent tryDotNetSrc, string hostOrigin, MarkdownPage page) =>
(TryDotNetSrc, HostOrigin, Page) = (tryDotNetSrc, hostOrigin, page);
public MarkdownPageViewModel(string hostOrigin, MarkdownPage page) =>
(HostOrigin, Page) = (hostOrigin, page);
}
}
9 changes: 0 additions & 9 deletions src/NodaTime.Web/Views/Documentation/Docs.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
ViewBag.Title = markdownPage.Title;
}

@section Scripts {
<script>
var editor = document.getElementById('trydotnet-editor');
if (editor != null) {
editor.setAttribute("src", "@Model.TryDotNetSrc&[email protected]");
}
</script>
}

<div class="row">
<div class="large-3 columns">
<ul class="side-nav">
Expand Down
1 change: 0 additions & 1 deletion src/NodaTime.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
<script src="/js/foundation/foundation.topbar.js"></script>
<script src="/js/highlight.pack.js"></script>
<script src="/js/nuget-button.js"></script>
<script src="/js/trydotnet.js"></script>
<script src="/js/site.js"></script>
</environment>
<environment names="Staging,Production">
Expand Down
4 changes: 0 additions & 4 deletions src/NodaTime.Web/appsettings.Staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@
],
"ForwardLimit": 2,
"ForwardedHeaders": [ "XForwardedFor", "XForwardedProto" ]
},

"TryDotNet": {
"Agent": "https://try.dot.net"
}
}
4 changes: 0 additions & 4 deletions src/NodaTime.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@
// to allow local development still using Google Cloud Storage, but
// without having to fetch all the data.
"BenchmarkLimit": null
},

"TryDotNet": {
"Agent": "https://try.dot.net"
}
}
3 changes: 1 addition & 2 deletions src/NodaTime.Web/bundleconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"wwwroot/js/foundation/foundation.topbar.js",
"wwwroot/js/highlight.pack.js",
"wwwroot/js/nuget-button.js",
"wwwroot/js/site.js",
"wwwroot/js/trydotnet.js"
"wwwroot/js/site.js"
],

"minify": {
Expand Down
43 changes: 0 additions & 43 deletions src/NodaTime.Web/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -425,49 +425,6 @@ td.pattern-example {
max-width: none;
}

.trydotnetbanner {
margin-top: 10px;
position: relative;
width: 100%;
overflow: hidden;
}

.trydotnetbanner > p {
margin: 0;
padding: 2px 4px;
font-size: 1em;
font-weight: normal;
color: #FFFFFF;
display: inline-block;
background-image: linear-gradient(to left, #B26F9E, #68217A);
}

.trydotnetbanner > p > a:link {
color: #FFFFFF;
}

.trydotnetbanner > p > a:visited {
color: #FFB8E9;
}

.trydotnetbanner > p > a:hover {
color: #FFFFFF;
}

.trydotnetbanner > p > a:active {
color: blue;
}

.trydotnetbutton {
padding: 8px;
border-radius: 4px;
margin-bottom: 10px;
}

.trydotnet-outputlabel {
margin-bottom: 10px;
}

.nsType {
/* !important is the simplest way to override the color from alternating table rows */
background-color: aliceblue !important;
Expand Down
114 changes: 0 additions & 114 deletions src/NodaTime.Web/wwwroot/js/trydotnet.js

This file was deleted.

0 comments on commit f749995

Please sign in to comment.