├── .gitattributes
├── .gitignore
├── .vscode
├── launch.json
└── tasks.json
├── BlazorBlog.sln
└── BlazorBlog
├── Client
├── App.razor
├── BlazorBlog.Client.csproj
├── Pages
│ ├── Counter.razor
│ ├── Create.razor
│ ├── FetchData.razor
│ ├── Index.razor
│ └── Post.razor
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Services
│ ├── BlogService.cs
│ └── IBlogService.cs
├── Shared
│ ├── BlogLayout.razor
│ ├── BlogPosts.razor
│ ├── MainLayout.razor
│ ├── NavMenu.razor
│ └── SurveyPrompt.razor
├── _Imports.razor
└── wwwroot
│ ├── css
│ ├── app.css
│ ├── bootstrap
│ │ ├── bootstrap.min.css
│ │ └── bootstrap.min.css.map
│ └── open-iconic
│ │ ├── FONT-LICENSE
│ │ ├── ICON-LICENSE
│ │ ├── README.md
│ │ └── font
│ │ ├── css
│ │ └── open-iconic-bootstrap.min.css
│ │ └── fonts
│ │ ├── open-iconic.eot
│ │ ├── open-iconic.otf
│ │ ├── open-iconic.svg
│ │ ├── open-iconic.ttf
│ │ └── open-iconic.woff
│ ├── favicon.ico
│ └── index.html
├── Server
├── BlazorBlog.Server.csproj
├── Controllers
│ ├── BlogController.cs
│ └── WeatherForecastController.cs
├── Data
│ └── DataContext.cs
├── Migrations
│ ├── 20201105051543_Initial.Designer.cs
│ ├── 20201105051543_Initial.cs
│ ├── 20201117045507_Image.Designer.cs
│ ├── 20201117045507_Image.cs
│ └── DataContextModelSnapshot.cs
├── Pages
│ ├── Error.cshtml
│ ├── Error.cshtml.cs
│ └── Shared
│ │ └── _Layout.cshtml
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Startup.cs
├── appsettings.Development.json
├── appsettings.json
└── blazorblog.db
└── Shared
├── BlazorBlog.Shared.csproj
├── BlogPost.cs
└── WeatherForecast.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Launch and Debug Standalone Blazor WebAssembly App",
9 | "type": "blazorwasm",
10 | "request": "launch",
11 | "cwd": "${workspaceFolder}/BlazorBlog/Server"
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/BlazorBlog/Server/BlazorBlog.Server.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/BlazorBlog/Server/BlazorBlog.Server.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/BlazorBlog/Server/BlazorBlog.Server.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/BlazorBlog.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30323.103
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorBlog.Server", "BlazorBlog\Server\BlazorBlog.Server.csproj", "{61CCD269-A281-475B-B72D-79D34AA7833D}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorBlog.Client", "BlazorBlog\Client\BlazorBlog.Client.csproj", "{8B928F8B-07A2-4E2B-A7A7-CB000C0A5A90}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorBlog.Shared", "BlazorBlog\Shared\BlazorBlog.Shared.csproj", "{1840CF21-2943-491A-8E95-65BBB06739D1}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {61CCD269-A281-475B-B72D-79D34AA7833D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {61CCD269-A281-475B-B72D-79D34AA7833D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {61CCD269-A281-475B-B72D-79D34AA7833D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {61CCD269-A281-475B-B72D-79D34AA7833D}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {8B928F8B-07A2-4E2B-A7A7-CB000C0A5A90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {8B928F8B-07A2-4E2B-A7A7-CB000C0A5A90}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {8B928F8B-07A2-4E2B-A7A7-CB000C0A5A90}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {8B928F8B-07A2-4E2B-A7A7-CB000C0A5A90}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {1840CF21-2943-491A-8E95-65BBB06739D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {1840CF21-2943-491A-8E95-65BBB06739D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {1840CF21-2943-491A-8E95-65BBB06739D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {1840CF21-2943-491A-8E95-65BBB06739D1}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {A3C26332-ED47-438E-B5A6-2867D8343AE7}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/App.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Sorry, there's nothing at this address.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/BlazorBlog.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Pages/Counter.razor:
--------------------------------------------------------------------------------
1 | @page "/counter"
2 |
3 |
Counter
4 |
5 | Current count: @currentCount
6 |
7 | Click me
8 |
9 | @code {
10 | private int currentCount = 0;
11 |
12 | private void IncrementCount()
13 | {
14 | currentCount++;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Pages/Create.razor:
--------------------------------------------------------------------------------
1 | @page "/create"
2 | @inject BlazorBlog.Client.Services.IBlogService BlogService
3 | @inject NavigationManager NavigationManager
4 |
5 | Create a New Blog Post
6 |
7 |
8 |
9 |
10 | Title
11 |
12 |
13 |
14 |
15 | Url
16 |
17 |
18 |
19 |
20 | Image
21 |
22 |
23 |
24 | Description
25 |
26 |
27 |
28 | Content
29 |
30 |
31 |
32 | Date
33 |
34 |
35 |
36 |
37 | Publish
38 |
39 | Create
40 |
41 |
42 |
43 | @code {
44 | BlazorBlog.Shared.BlogPost newBlogPost = new BlazorBlog.Shared.BlogPost();
45 |
46 | async Task CreateNewBlogPost()
47 | {
48 | var result = await BlogService.CreateNewBlogPost(newBlogPost);
49 | NavigationManager.NavigateTo($"posts/{result.Url}");
50 | }
51 |
52 | async Task OnFileChange(InputFileChangeEventArgs e)
53 | {
54 | var format = "image/png";
55 | var resizedImage = await e.File.RequestImageFileAsync(format, 1060, 1060);
56 | var buffer = new byte[resizedImage.Size];
57 | await resizedImage.OpenReadStream().ReadAsync(buffer);
58 | var imageData = $"data:{format};base64,{Convert.ToBase64String(buffer)}";
59 | newBlogPost.Image = imageData;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Pages/FetchData.razor:
--------------------------------------------------------------------------------
1 | @page "/fetchdata"
2 | @using BlazorBlog.Shared
3 | @inject HttpClient Http
4 |
5 | Weather forecast
6 |
7 | This component demonstrates fetching data from the server.
8 |
9 | @if (forecasts == null)
10 | {
11 | Loading...
12 | }
13 | else
14 | {
15 |
16 |
17 |
18 | Date
19 | Temp. (C)
20 | Temp. (F)
21 | Summary
22 |
23 |
24 |
25 | @foreach (var forecast in forecasts)
26 | {
27 |
28 | @forecast.Date.ToShortDateString()
29 | @forecast.TemperatureC
30 | @forecast.TemperatureF
31 | @forecast.Summary
32 |
33 | }
34 |
35 |
36 | }
37 |
38 | @code {
39 | private WeatherForecast[] forecasts;
40 |
41 | protected override async Task OnInitializedAsync()
42 | {
43 | forecasts = await Http.GetFromJsonAsync("WeatherForecast");
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 | Welcome to my blog!
4 |
5 | Here are my latest posts. Enjoy!
6 |
7 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Pages/Post.razor:
--------------------------------------------------------------------------------
1 | @page "/posts/{url}"
2 | @inject BlazorBlog.Client.Services.IBlogService BlogService
3 |
4 | @if (CurrentPost == null)
5 | {
6 | Getting that blog post from the service...
7 | }
8 | else
9 | {
10 |
11 |
12 | @CurrentPost.Title
13 |
14 |
15 | @CurrentPost.Content
16 |
17 | }
18 |
19 | @code {
20 | private BlazorBlog.Shared.BlogPost CurrentPost;
21 |
22 | [Parameter]
23 | public string Url { get; set; }
24 |
25 | string placeholderImage = "https://via.placeholder.com/1060x300";
26 |
27 | protected override async Task OnInitializedAsync()
28 | {
29 | CurrentPost = await BlogService.GetBlogPostByUrl(Url);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 | using System.Text;
6 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 | using BlazorBlog.Client.Services;
11 |
12 | namespace BlazorBlog.Client
13 | {
14 | public class Program
15 | {
16 | public static async Task Main(string[] args)
17 | {
18 | var builder = WebAssemblyHostBuilder.CreateDefault(args);
19 | builder.RootComponents.Add("app");
20 |
21 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
22 | builder.Services.AddScoped();
23 |
24 | await builder.Build().RunAsync();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61847",
7 | "sslPort": 44365
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "BlazorBlog": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Services/BlogService.cs:
--------------------------------------------------------------------------------
1 | using BlazorBlog.Shared;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net.Http;
6 | using System.Net.Http.Json;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlazorBlog.Client.Services
10 | {
11 | public class BlogService : IBlogService
12 | {
13 | private readonly HttpClient _http;
14 |
15 | public BlogService(HttpClient http)
16 | {
17 | _http = http;
18 | }
19 |
20 | public async Task CreateNewBlogPost(BlogPost request)
21 | {
22 | var result = await _http.PostAsJsonAsync("api/Blog", request);
23 | return await result.Content.ReadFromJsonAsync();
24 | }
25 |
26 | public async Task GetBlogPostByUrl(string url)
27 | {
28 | //var post = await _http.GetFromJsonAsync($"api/Blog/{url}");
29 | //return post;
30 |
31 | var result = await _http.GetAsync($"api/Blog/{url}");
32 | if (result.StatusCode != System.Net.HttpStatusCode.OK)
33 | {
34 | var message = await result.Content.ReadAsStringAsync();
35 | Console.WriteLine(message);
36 | return new BlogPost { Title = message };
37 | }
38 | else
39 | {
40 | return await result.Content.ReadFromJsonAsync();
41 | }
42 | }
43 |
44 | public async Task> GetBlogPosts()
45 | {
46 | return await _http.GetFromJsonAsync>("api/Blog");
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Services/IBlogService.cs:
--------------------------------------------------------------------------------
1 | using BlazorBlog.Shared;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 |
7 | namespace BlazorBlog.Client.Services
8 | {
9 | interface IBlogService
10 | {
11 | Task> GetBlogPosts();
12 | Task GetBlogPostByUrl(string url);
13 | Task CreateNewBlogPost(BlogPost request);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Shared/BlogLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
4 |
5 |
6 | @Body
7 |
8 |
9 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Shared/BlogPosts.razor:
--------------------------------------------------------------------------------
1 | @using BlazorBlog.Shared
2 | @inject BlazorBlog.Client.Services.IBlogService BlogService
3 |
4 | @foreach (var post in Posts)
5 | {
6 |
7 |
8 |
9 |
@post.Title
10 |
@post.Description
11 |
@post.DateCreated.ToLongDateString()
12 |
Read more...
13 |
14 |
15 | }
16 |
17 |
18 | @code {
19 | private List Posts = new List();
20 |
21 | string placeholderImage = "https://via.placeholder.com/1060x180";
22 |
23 | protected override async Task OnInitializedAsync()
24 | {
25 | Posts = await BlogService.GetBlogPosts();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
6 |
7 |
8 |
11 |
12 |
13 | @Body
14 |
15 |
16 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Shared/NavMenu.razor:
--------------------------------------------------------------------------------
1 |
2 | Blazor Blog
3 |
4 |
5 |
6 |
7 |
21 |
22 |
23 | @code {
24 | private bool collapseNavMenu = true;
25 |
26 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
27 |
28 | private void ToggleNavMenu()
29 | {
30 | collapseNavMenu = !collapseNavMenu;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/Shared/SurveyPrompt.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
@Title
4 |
5 |
6 | Please take our
7 | brief survey
8 |
9 | and tell us what you think.
10 |
11 |
12 | @code {
13 | // Demonstrates how a parent component can supply parameters
14 | [Parameter]
15 | public string Title { get; set; }
16 | }
17 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using System.Net.Http.Json
3 | @using Microsoft.AspNetCore.Components.Forms
4 | @using Microsoft.AspNetCore.Components.Routing
5 | @using Microsoft.AspNetCore.Components.Web
6 | @using Microsoft.AspNetCore.Components.WebAssembly.Http
7 | @using Microsoft.JSInterop
8 | @using BlazorBlog.Client
9 | @using BlazorBlog.Client.Shared
10 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/app.css:
--------------------------------------------------------------------------------
1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
2 |
3 | html, body {
4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
5 | }
6 |
7 | a, .btn-link {
8 | color: #0366d6;
9 | }
10 |
11 | .btn-primary {
12 | color: #fff;
13 | background-color: #1b6ec2;
14 | border-color: #1861ac;
15 | }
16 |
17 | app {
18 | position: relative;
19 | display: flex;
20 | flex-direction: column;
21 | }
22 |
23 | .top-row {
24 | height: 3.5rem;
25 | display: flex;
26 | align-items: center;
27 | }
28 |
29 | .main {
30 | flex: 1;
31 | }
32 |
33 | .main .top-row {
34 | background-color: #f7f7f7;
35 | border-bottom: 1px solid #d6d5d5;
36 | justify-content: flex-end;
37 | }
38 |
39 | .main .top-row > a, .main .top-row .btn-link {
40 | white-space: nowrap;
41 | margin-left: 1.5rem;
42 | }
43 |
44 | .main .top-row a:first-child {
45 | overflow: hidden;
46 | text-overflow: ellipsis;
47 | }
48 |
49 | .sidebar {
50 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
51 | }
52 |
53 | .sidebar .top-row {
54 | background-color: rgba(0,0,0,0.4);
55 | }
56 |
57 | .sidebar .navbar-brand {
58 | font-size: 1.1rem;
59 | }
60 |
61 | .sidebar .oi {
62 | width: 2rem;
63 | font-size: 1.1rem;
64 | vertical-align: text-top;
65 | top: -2px;
66 | }
67 |
68 | .sidebar .nav-item {
69 | font-size: 0.9rem;
70 | padding-bottom: 0.5rem;
71 | }
72 |
73 | .sidebar .nav-item:first-of-type {
74 | padding-top: 1rem;
75 | }
76 |
77 | .sidebar .nav-item:last-of-type {
78 | padding-bottom: 1rem;
79 | }
80 |
81 | .sidebar .nav-item a {
82 | color: #d7d7d7;
83 | border-radius: 4px;
84 | height: 3rem;
85 | display: flex;
86 | align-items: center;
87 | line-height: 3rem;
88 | }
89 |
90 | .sidebar .nav-item a.active {
91 | background-color: rgba(255,255,255,0.25);
92 | color: white;
93 | }
94 |
95 | .sidebar .nav-item a:hover {
96 | background-color: rgba(255,255,255,0.1);
97 | color: white;
98 | }
99 |
100 | .content {
101 | padding-top: 1.1rem;
102 | }
103 |
104 | .navbar-toggler {
105 | background-color: rgba(255, 255, 255, 0.1);
106 | }
107 |
108 | .valid.modified:not([type=checkbox]) {
109 | outline: 1px solid #26b050;
110 | }
111 |
112 | .invalid {
113 | outline: 1px solid red;
114 | }
115 |
116 | .validation-message {
117 | color: red;
118 | }
119 |
120 | #blazor-error-ui {
121 | background: lightyellow;
122 | bottom: 0;
123 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
124 | display: none;
125 | left: 0;
126 | padding: 0.6rem 1.25rem 0.7rem 1.25rem;
127 | position: fixed;
128 | width: 100%;
129 | z-index: 1000;
130 | }
131 |
132 | #blazor-error-ui .dismiss {
133 | cursor: pointer;
134 | position: absolute;
135 | right: 0.75rem;
136 | top: 0.5rem;
137 | }
138 |
139 | .card-img {
140 | height: 180px;
141 | background-size: cover;
142 | background-position: center;
143 | border-radius: 6px;
144 | margin-bottom: 10px;
145 | }
146 |
147 | .post-img {
148 | height: 300px;
149 | background-size: cover;
150 | background-position: center;
151 | border-radius: 6px;
152 | margin-bottom: 10px;
153 | }
154 |
155 | @media (max-width: 767.98px) {
156 | .main .top-row:not(.auth) {
157 | display: none;
158 | }
159 |
160 | .main .top-row.auth {
161 | justify-content: space-between;
162 | }
163 |
164 | .main .top-row a, .main .top-row .btn-link {
165 | margin-left: 0;
166 | }
167 | }
168 |
169 | @media (min-width: 768px) {
170 | app {
171 | flex-direction: row;
172 | }
173 |
174 | .sidebar {
175 | width: 250px;
176 | height: 100vh;
177 | position: sticky;
178 | top: 0;
179 | }
180 |
181 | .main .top-row {
182 | position: sticky;
183 | top: 0;
184 | }
185 |
186 | .main > div {
187 | padding-left: 2rem !important;
188 | padding-right: 1.5rem !important;
189 | }
190 |
191 | .navbar-toggler {
192 | display: none;
193 | }
194 |
195 | .sidebar .collapse {
196 | /* Never collapse the sidebar for wide screens */
197 | display: block;
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/FONT-LICENSE:
--------------------------------------------------------------------------------
1 | SIL OPEN FONT LICENSE Version 1.1
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | PREAMBLE
6 | The goals of the Open Font License (OFL) are to stimulate worldwide
7 | development of collaborative font projects, to support the font creation
8 | efforts of academic and linguistic communities, and to provide a free and
9 | open framework in which fonts may be shared and improved in partnership
10 | with others.
11 |
12 | The OFL allows the licensed fonts to be used, studied, modified and
13 | redistributed freely as long as they are not sold by themselves. The
14 | fonts, including any derivative works, can be bundled, embedded,
15 | redistributed and/or sold with any software provided that any reserved
16 | names are not used by derivative works. The fonts and derivatives,
17 | however, cannot be released under any other type of license. The
18 | requirement for fonts to remain under this license does not apply
19 | to any document created using the fonts or their derivatives.
20 |
21 | DEFINITIONS
22 | "Font Software" refers to the set of files released by the Copyright
23 | Holder(s) under this license and clearly marked as such. This may
24 | include source files, build scripts and documentation.
25 |
26 | "Reserved Font Name" refers to any names specified as such after the
27 | copyright statement(s).
28 |
29 | "Original Version" refers to the collection of Font Software components as
30 | distributed by the Copyright Holder(s).
31 |
32 | "Modified Version" refers to any derivative made by adding to, deleting,
33 | or substituting -- in part or in whole -- any of the components of the
34 | Original Version, by changing formats or by porting the Font Software to a
35 | new environment.
36 |
37 | "Author" refers to any designer, engineer, programmer, technical
38 | writer or other person who contributed to the Font Software.
39 |
40 | PERMISSION & CONDITIONS
41 | Permission is hereby granted, free of charge, to any person obtaining
42 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
43 | redistribute, and sell modified and unmodified copies of the Font
44 | Software, subject to the following conditions:
45 |
46 | 1) Neither the Font Software nor any of its individual components,
47 | in Original or Modified Versions, may be sold by itself.
48 |
49 | 2) Original or Modified Versions of the Font Software may be bundled,
50 | redistributed and/or sold with any software, provided that each copy
51 | contains the above copyright notice and this license. These can be
52 | included either as stand-alone text files, human-readable headers or
53 | in the appropriate machine-readable metadata fields within text or
54 | binary files as long as those fields can be easily viewed by the user.
55 |
56 | 3) No Modified Version of the Font Software may use the Reserved Font
57 | Name(s) unless explicit written permission is granted by the corresponding
58 | Copyright Holder. This restriction only applies to the primary font name as
59 | presented to the users.
60 |
61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
62 | Software shall not be used to promote, endorse or advertise any
63 | Modified Version, except to acknowledge the contribution(s) of the
64 | Copyright Holder(s) and the Author(s) or with their explicit written
65 | permission.
66 |
67 | 5) The Font Software, modified or unmodified, in part or in whole,
68 | must be distributed entirely under this license, and must not be
69 | distributed under any other license. The requirement for fonts to
70 | remain under this license does not apply to any document created
71 | using the Font Software.
72 |
73 | TERMINATION
74 | This license becomes null and void if any of the above conditions are
75 | not met.
76 |
77 | DISCLAIMER
78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
86 | OTHER DEALINGS IN THE FONT SOFTWARE.
87 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/README.md:
--------------------------------------------------------------------------------
1 | [Open Iconic v1.1.1](http://useiconic.com/open)
2 | ===========
3 |
4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
5 |
6 |
7 |
8 | ## What's in Open Iconic?
9 |
10 | * 223 icons designed to be legible down to 8 pixels
11 | * Super-light SVG files - 61.8 for the entire set
12 | * SVG sprite—the modern replacement for icon fonts
13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
16 |
17 |
18 | ## Getting Started
19 |
20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
21 |
22 | ### General Usage
23 |
24 | #### Using Open Iconic's SVGs
25 |
26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
27 |
28 | ```
29 |
30 | ```
31 |
32 | #### Using Open Iconic's SVG Sprite
33 |
34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
35 |
36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.*
37 |
38 | ```
39 |
40 |
41 |
42 | ```
43 |
44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions.
45 |
46 | ```
47 | .icon {
48 | width: 16px;
49 | height: 16px;
50 | }
51 | ```
52 |
53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag.
54 |
55 | ```
56 | .icon-account-login {
57 | fill: #f00;
58 | }
59 | ```
60 |
61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/).
62 |
63 | #### Using Open Iconic's Icon Font...
64 |
65 |
66 | ##### …with Bootstrap
67 |
68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}`
69 |
70 |
71 | ```
72 |
73 | ```
74 |
75 |
76 | ```
77 |
78 | ```
79 |
80 | ##### …with Foundation
81 |
82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}`
83 |
84 | ```
85 |
86 | ```
87 |
88 |
89 | ```
90 |
91 | ```
92 |
93 | ##### …on its own
94 |
95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}`
96 |
97 | ```
98 |
99 | ```
100 |
101 | ```
102 |
103 | ```
104 |
105 |
106 | ## License
107 |
108 | ### Icons
109 |
110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT).
111 |
112 | ### Fonts
113 |
114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web).
115 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css:
--------------------------------------------------------------------------------
1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'}
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014
9 | By P.J. Onori
10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net)
11 |
12 |
13 |
14 |
27 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
45 |
47 |
49 |
51 |
53 |
55 |
57 |
59 |
61 |
63 |
65 |
67 |
69 |
71 |
74 |
76 |
79 |
81 |
84 |
86 |
88 |
91 |
93 |
95 |
98 |
100 |
102 |
104 |
106 |
109 |
112 |
115 |
117 |
121 |
123 |
125 |
127 |
130 |
132 |
134 |
136 |
138 |
141 |
143 |
145 |
147 |
149 |
151 |
153 |
155 |
157 |
159 |
162 |
165 |
167 |
169 |
172 |
174 |
177 |
179 |
181 |
183 |
185 |
189 |
191 |
194 |
196 |
198 |
200 |
202 |
205 |
207 |
209 |
211 |
213 |
215 |
218 |
220 |
222 |
224 |
226 |
228 |
230 |
232 |
234 |
236 |
238 |
241 |
243 |
245 |
247 |
249 |
251 |
253 |
256 |
259 |
261 |
263 |
265 |
267 |
269 |
272 |
274 |
276 |
280 |
282 |
285 |
287 |
289 |
292 |
295 |
298 |
300 |
302 |
304 |
306 |
309 |
312 |
314 |
316 |
318 |
320 |
322 |
324 |
326 |
330 |
334 |
338 |
340 |
343 |
345 |
347 |
349 |
351 |
353 |
355 |
358 |
360 |
363 |
365 |
367 |
369 |
371 |
373 |
375 |
377 |
379 |
381 |
383 |
386 |
388 |
390 |
392 |
394 |
396 |
399 |
401 |
404 |
406 |
408 |
410 |
412 |
414 |
416 |
419 |
421 |
423 |
425 |
428 |
431 |
435 |
438 |
440 |
442 |
444 |
446 |
448 |
451 |
453 |
455 |
457 |
460 |
462 |
464 |
466 |
468 |
471 |
473 |
477 |
479 |
481 |
483 |
486 |
488 |
490 |
492 |
494 |
496 |
499 |
501 |
504 |
506 |
509 |
512 |
515 |
517 |
520 |
522 |
524 |
526 |
529 |
532 |
534 |
536 |
539 |
542 |
543 |
544 |
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Client/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/BlazorBlog/Client/wwwroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | BlazorBlog
8 |
9 |
10 |
11 |
12 |
13 |
14 | Loading...
15 |
16 |
17 | An unhandled error has occurred.
18 |
Reload
19 |
🗙
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/BlazorBlog.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 | all
12 | runtime; build; native; contentfiles; analyzers; buildtransitive
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Controllers/BlogController.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 | using BlazorBlog.Server.Data;
5 | using BlazorBlog.Shared;
6 | using Microsoft.AspNetCore.Mvc;
7 |
8 | namespace BlazorBlog.Server.Controllers
9 | {
10 | [Route("api/[controller]")]
11 | [ApiController]
12 | public class BlogController : ControllerBase
13 | {
14 | private readonly DataContext _context;
15 |
16 | public BlogController(DataContext context)
17 | {
18 | _context = context;
19 | }
20 |
21 | [HttpGet]
22 | public ActionResult> GimmeAllTheBlogPosts()
23 | {
24 | return Ok(_context.BlogPosts.OrderByDescending(post => post.DateCreated));
25 | }
26 |
27 | [HttpGet("{url}")]
28 | public ActionResult GimmeThatSingleBlogPost(string url)
29 | {
30 | var post = _context.BlogPosts.FirstOrDefault(p => p.Url.ToLower().Equals(url.ToLower()));
31 | if (post == null)
32 | {
33 | return NotFound("This post does not exist.");
34 | }
35 |
36 | return Ok(post);
37 | }
38 |
39 | [HttpPost]
40 | public async Task> CreateNewBlogPost(BlogPost request)
41 | {
42 | _context.Add(request);
43 | await _context.SaveChangesAsync();
44 |
45 | return request;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using BlazorBlog.Shared;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.Extensions.Logging;
8 |
9 | namespace BlazorBlog.Server.Controllers
10 | {
11 | [ApiController]
12 | [Route("[controller]")]
13 | public class WeatherForecastController : ControllerBase
14 | {
15 | private static readonly string[] Summaries = new[]
16 | {
17 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
18 | };
19 |
20 | private readonly ILogger logger;
21 |
22 | public WeatherForecastController(ILogger logger)
23 | {
24 | this.logger = logger;
25 | }
26 |
27 | [HttpGet]
28 | public IEnumerable Get()
29 | {
30 | var rng = new Random();
31 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
32 | {
33 | Date = DateTime.Now.AddDays(index),
34 | TemperatureC = rng.Next(-20, 55),
35 | Summary = Summaries[rng.Next(Summaries.Length)]
36 | })
37 | .ToArray();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Data/DataContext.cs:
--------------------------------------------------------------------------------
1 | using BlazorBlog.Shared;
2 | using Microsoft.EntityFrameworkCore;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlazorBlog.Server.Data
9 | {
10 | public class DataContext : DbContext
11 | {
12 | public DataContext(DbContextOptions options) : base(options)
13 | {
14 |
15 | }
16 |
17 | public DbSet BlogPosts { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Migrations/20201105051543_Initial.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using BlazorBlog.Server.Data;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 |
9 | namespace BlazorBlog.Server.Migrations
10 | {
11 | [DbContext(typeof(DataContext))]
12 | [Migration("20201105051543_Initial")]
13 | partial class Initial
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | #pragma warning disable 612, 618
18 | modelBuilder
19 | .HasAnnotation("ProductVersion", "3.1.9");
20 |
21 | modelBuilder.Entity("BlazorBlog.Shared.BlogPost", b =>
22 | {
23 | b.Property("Id")
24 | .ValueGeneratedOnAdd()
25 | .HasColumnType("INTEGER");
26 |
27 | b.Property("Author")
28 | .HasColumnType("TEXT");
29 |
30 | b.Property("Content")
31 | .HasColumnType("TEXT");
32 |
33 | b.Property("DateCreated")
34 | .HasColumnType("TEXT");
35 |
36 | b.Property("Description")
37 | .HasColumnType("TEXT");
38 |
39 | b.Property("IsDeleted")
40 | .HasColumnType("INTEGER");
41 |
42 | b.Property("IsPublished")
43 | .HasColumnType("INTEGER");
44 |
45 | b.Property("Title")
46 | .HasColumnType("TEXT");
47 |
48 | b.Property("Url")
49 | .HasColumnType("TEXT");
50 |
51 | b.HasKey("Id");
52 |
53 | b.ToTable("BlogPosts");
54 | });
55 | #pragma warning restore 612, 618
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Migrations/20201105051543_Initial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | namespace BlazorBlog.Server.Migrations
5 | {
6 | public partial class Initial : Migration
7 | {
8 | protected override void Up(MigrationBuilder migrationBuilder)
9 | {
10 | migrationBuilder.CreateTable(
11 | name: "BlogPosts",
12 | columns: table => new
13 | {
14 | Id = table.Column(nullable: false)
15 | .Annotation("Sqlite:Autoincrement", true),
16 | Url = table.Column(nullable: true),
17 | Title = table.Column(nullable: true),
18 | Content = table.Column(nullable: true),
19 | Description = table.Column(nullable: true),
20 | Author = table.Column(nullable: true),
21 | DateCreated = table.Column(nullable: false),
22 | IsPublished = table.Column(nullable: false),
23 | IsDeleted = table.Column(nullable: false)
24 | },
25 | constraints: table =>
26 | {
27 | table.PrimaryKey("PK_BlogPosts", x => x.Id);
28 | });
29 | }
30 |
31 | protected override void Down(MigrationBuilder migrationBuilder)
32 | {
33 | migrationBuilder.DropTable(
34 | name: "BlogPosts");
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Migrations/20201117045507_Image.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using BlazorBlog.Server.Data;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Migrations;
7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8 |
9 | namespace BlazorBlog.Server.Migrations
10 | {
11 | [DbContext(typeof(DataContext))]
12 | [Migration("20201117045507_Image")]
13 | partial class Image
14 | {
15 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
16 | {
17 | #pragma warning disable 612, 618
18 | modelBuilder
19 | .HasAnnotation("ProductVersion", "5.0.0");
20 |
21 | modelBuilder.Entity("BlazorBlog.Shared.BlogPost", b =>
22 | {
23 | b.Property("Id")
24 | .ValueGeneratedOnAdd()
25 | .HasColumnType("INTEGER");
26 |
27 | b.Property("Author")
28 | .HasColumnType("TEXT");
29 |
30 | b.Property("Content")
31 | .HasColumnType("TEXT");
32 |
33 | b.Property("DateCreated")
34 | .HasColumnType("TEXT");
35 |
36 | b.Property("Description")
37 | .HasColumnType("TEXT");
38 |
39 | b.Property("Image")
40 | .HasColumnType("TEXT");
41 |
42 | b.Property("IsDeleted")
43 | .HasColumnType("INTEGER");
44 |
45 | b.Property("IsPublished")
46 | .HasColumnType("INTEGER");
47 |
48 | b.Property("Title")
49 | .IsRequired()
50 | .HasColumnType("TEXT");
51 |
52 | b.Property("Url")
53 | .IsRequired()
54 | .HasMaxLength(20)
55 | .HasColumnType("TEXT");
56 |
57 | b.HasKey("Id");
58 |
59 | b.ToTable("BlogPosts");
60 | });
61 | #pragma warning restore 612, 618
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Migrations/20201117045507_Image.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace BlazorBlog.Server.Migrations
4 | {
5 | public partial class Image : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.AlterColumn(
10 | name: "Url",
11 | table: "BlogPosts",
12 | type: "TEXT",
13 | maxLength: 20,
14 | nullable: false,
15 | defaultValue: "",
16 | oldClrType: typeof(string),
17 | oldType: "TEXT",
18 | oldNullable: true);
19 |
20 | migrationBuilder.AlterColumn(
21 | name: "Title",
22 | table: "BlogPosts",
23 | type: "TEXT",
24 | nullable: false,
25 | defaultValue: "",
26 | oldClrType: typeof(string),
27 | oldType: "TEXT",
28 | oldNullable: true);
29 |
30 | migrationBuilder.AddColumn(
31 | name: "Image",
32 | table: "BlogPosts",
33 | type: "TEXT",
34 | nullable: true);
35 | }
36 |
37 | protected override void Down(MigrationBuilder migrationBuilder)
38 | {
39 | migrationBuilder.DropColumn(
40 | name: "Image",
41 | table: "BlogPosts");
42 |
43 | migrationBuilder.AlterColumn(
44 | name: "Url",
45 | table: "BlogPosts",
46 | type: "TEXT",
47 | nullable: true,
48 | oldClrType: typeof(string),
49 | oldType: "TEXT",
50 | oldMaxLength: 20);
51 |
52 | migrationBuilder.AlterColumn(
53 | name: "Title",
54 | table: "BlogPosts",
55 | type: "TEXT",
56 | nullable: true,
57 | oldClrType: typeof(string),
58 | oldType: "TEXT");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Migrations/DataContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using BlazorBlog.Server.Data;
4 | using Microsoft.EntityFrameworkCore;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7 |
8 | namespace BlazorBlog.Server.Migrations
9 | {
10 | [DbContext(typeof(DataContext))]
11 | partial class DataContextModelSnapshot : ModelSnapshot
12 | {
13 | protected override void BuildModel(ModelBuilder modelBuilder)
14 | {
15 | #pragma warning disable 612, 618
16 | modelBuilder
17 | .HasAnnotation("ProductVersion", "5.0.0");
18 |
19 | modelBuilder.Entity("BlazorBlog.Shared.BlogPost", b =>
20 | {
21 | b.Property("Id")
22 | .ValueGeneratedOnAdd()
23 | .HasColumnType("INTEGER");
24 |
25 | b.Property("Author")
26 | .HasColumnType("TEXT");
27 |
28 | b.Property("Content")
29 | .HasColumnType("TEXT");
30 |
31 | b.Property("DateCreated")
32 | .HasColumnType("TEXT");
33 |
34 | b.Property("Description")
35 | .HasColumnType("TEXT");
36 |
37 | b.Property("Image")
38 | .HasColumnType("TEXT");
39 |
40 | b.Property("IsDeleted")
41 | .HasColumnType("INTEGER");
42 |
43 | b.Property("IsPublished")
44 | .HasColumnType("INTEGER");
45 |
46 | b.Property("Title")
47 | .IsRequired()
48 | .HasColumnType("TEXT");
49 |
50 | b.Property("Url")
51 | .IsRequired()
52 | .HasMaxLength(20)
53 | .HasColumnType("TEXT");
54 |
55 | b.HasKey("Id");
56 |
57 | b.ToTable("BlogPosts");
58 | });
59 | #pragma warning restore 612, 618
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Pages/Error.cshtml:
--------------------------------------------------------------------------------
1 | @page
2 | @model BlazorBlog.Server.Pages.ErrorModel
3 | @{
4 | Layout = "_Layout";
5 | ViewData["Title"] = "Error";
6 | }
7 |
8 | Error.
9 | An error occurred while processing your request.
10 |
11 | @if (Model.ShowRequestId)
12 | {
13 |
14 | Request ID: @Model.RequestId
15 |
16 | }
17 |
18 | Development Mode
19 |
20 | Swapping to the Development environment displays detailed information about the error that occurred.
21 |
22 |
23 | The Development environment shouldn't be enabled for deployed applications.
24 | It can result in displaying sensitive information from exceptions to end users.
25 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
26 | and restarting the app.
27 |
28 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Pages/Error.cshtml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.AspNetCore.Mvc.RazorPages;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace BlazorBlog.Server.Pages
11 | {
12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13 | public class ErrorModel : PageModel
14 | {
15 | public string RequestId { get; set; }
16 |
17 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
18 |
19 | private readonly ILogger _logger;
20 |
21 | public ErrorModel(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | public void OnGet()
27 | {
28 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Pages/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | @ViewBag.Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | @RenderBody()
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace BlazorBlog.Server
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61847",
7 | "sslPort": 44365
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "BlazorBlog.Server": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.HttpsPolicy;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.AspNetCore.ResponseCompression;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using System.Linq;
9 | using BlazorBlog.Server.Data;
10 | using Microsoft.EntityFrameworkCore;
11 |
12 | namespace BlazorBlog.Server
13 | {
14 | public class Startup
15 | {
16 | public Startup(IConfiguration configuration)
17 | {
18 | Configuration = configuration;
19 | }
20 |
21 | public IConfiguration Configuration { get; }
22 |
23 | // This method gets called by the runtime. Use this method to add services to the container.
24 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
25 | public void ConfigureServices(IServiceCollection services)
26 | {
27 | services.AddDbContext(x => x.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
28 | services.AddControllersWithViews();
29 | services.AddRazorPages();
30 | }
31 |
32 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
33 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
34 | {
35 | if (env.IsDevelopment())
36 | {
37 | app.UseDeveloperExceptionPage();
38 | app.UseWebAssemblyDebugging();
39 | }
40 | else
41 | {
42 | app.UseExceptionHandler("/Error");
43 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
44 | app.UseHsts();
45 | }
46 |
47 | app.UseHttpsRedirection();
48 | app.UseBlazorFrameworkFiles();
49 | app.UseStaticFiles();
50 |
51 | app.UseRouting();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapRazorPages();
56 | endpoints.MapControllers();
57 | endpoints.MapFallbackToFile("index.html");
58 | });
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "DefaultConnection": "Data Source=blazorblog.db"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft": "Warning",
9 | "Microsoft.Hosting.Lifetime": "Information"
10 | }
11 | },
12 | "AllowedHosts": "*"
13 | }
14 |
--------------------------------------------------------------------------------
/BlazorBlog/Server/blazorblog.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickgod/BlazorBlog/60db0f59dbcafd8bf8f8ad92d3d1a78e8156a39f/BlazorBlog/Server/blazorblog.db
--------------------------------------------------------------------------------
/BlazorBlog/Shared/BlazorBlog.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/BlazorBlog/Shared/BlogPost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Runtime.CompilerServices;
5 | using System.Text;
6 |
7 | namespace BlazorBlog.Shared
8 | {
9 | public class BlogPost
10 | {
11 | public int Id { get; set; }
12 | [Required, StringLength(20, ErrorMessage = "Please use only 20 characters.")]
13 | public string Url { get; set; }
14 |
15 | public string Image { get; set; }
16 |
17 | [Required]
18 | public string Title { get; set; }
19 |
20 | public string Content { get; set; }
21 |
22 | public string Description { get; set; }
23 |
24 | public string Author { get; set; }
25 |
26 | public DateTime DateCreated { get; set; } = DateTime.Now;
27 |
28 | public bool IsPublished { get; set; } = true;
29 |
30 | public bool IsDeleted { get; set; } = false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/BlazorBlog/Shared/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BlazorBlog.Shared
6 | {
7 | public class WeatherForecast
8 | {
9 | public DateTime Date { get; set; }
10 |
11 | public int TemperatureC { get; set; }
12 |
13 | public string Summary { get; set; }
14 |
15 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------