rayrfan / fanray Goto Github PK
View Code? Open in Web Editor NEWA blog built with ASP.NET Core
License: Apache License 2.0
A blog built with ASP.NET Core
License: Apache License 2.0
This class helps with the creation of FanDbContext with SQLite in memory database and EF Core InMemory Provider, as well as seeding initial blog data that some of the tests depend on.
The underlying structure for all settings is Meta which is a key value object store, on top of this are services that need to save objects in database. For example, SettingService, WidgetService.
Meta can be queried with a key, for example Fan.Models.SiteSettings is the key to get the site settings meta record back. Meta can also be queried to return a list of meta records, for example, I want all widgets settings, meta can return based on "StartsWith", "EndsWith", "Contains" on the key.
By default
This would give the best out-of-box experience.
Thus, I'm adding a setting in appsettings.json
"Database": {
"UseSqLite": false
}
and in appsettings.Development.json
"Database": {
"UseSqLite": true
}
When we throw our own exception, we may want to carry with it the validation messages.
When user creates a Post, the post title
When user creates a Category, the category title
I need validtor for each of the two classes.
When appsettings.json is updated the setting changes should be reflected automatically.
I need to revamp Program.cs
I'm trying to tighten up a project with its responsibilities. MetaWeblog is an endpoint for OLW, so is BlogController which is an endpoint for browser that consumes html. I'm moving both of these into Fan.Blogs.
Added
Still need author, this needs to want for Identity update
Ref
https://www.sitepoint.com/meta-tags-html-basics-best-practices/
See if Fan, Fan.Blogs projects can go from "netcoreapp2.0" to "netstandard2.0"
A hard decision but one worth making. I've supported Sqlite throughout v1 alpha and betas, the benefits of using Sqlite include:
However, supporting both Sqlite and SqlServer means I cannot easily maintain migrations in my code, because there has to be one set of migrations to keep for each db vendor I support, this is messy.
Coming back to supporting only Sql Server, means user needs to have Sql Server pre-installed on their machine, and possibly adjust the connection string, before running the app. This is a minor inconvenience compared to having migrations in my code, benefits include:
So far I'm able to use multiple dbcontextes, one for Fan named CoreDbContext
and one for Fan.Blogs named BlogDbContext
, however I have to carry an over-all dbcontext FanDbContext
in Fan.Web which is needed to do migration in startup.
Every time I add a new app or plugin I have to update startup.cs, this is not really convenient, I need to find a way to use reflection and do this part automatically.
Should I use UniqueId instead of Id on data-disqus-identifier and page.identifier?
I have decided not to use guid, but instead have a Fan.Enums.ECommentTargetType, a discussion system will eventually be storing these comments, as such it needs to know a comment is for which target.
Currently page.identifier is "BlogPost_{id}"
https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
shortname
this.page.identifier
this.page.title
this.page.url
this.page.category_id
shortname https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
Disqus identifier https://help.disqus.com/customer/portal/articles/472099-what-is-a-disqus-identifier-
https://help.disqus.com/customer/portal/articles/472099-what-is-a-disqus-identifier-
https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables
https://code.tutsplus.com/tutorials/integrating-disqus-into-wordpress--wp-25799
https://disqus.com/admin/ click on your site and scroll down choose universal code
https://fanray.disqus.com/admin/settings/universalcode/
https://blog.disqus.com/little-known-disqus-features?utm_source=motd_admin&utm_medium=web
https://help.disqus.com/customer/portal/articles/565624-adding-comment-count-links-to-your-home-page
https://ray247.wordpress.com/2009/09/02/how-to-develop-with-disqus-on-localhost/
https://stackoverflow.com/questions/9475821/disqus-comments-fails-to-load-on-localhost
Create SqlCategoryRepoistory and test it with Sqlite in memory db tests.
Use the new rss lib in .net core: https://github.com/dotnet/SyndicationFeedReaderWriter to generate the main and category feeds. Rss Ref: https://www.w3schools.com/xml/xml_rss.asp#rssref
When user runs the app for the first time, it goes to a setup page asking simple info so it could create the blog and an admin user. The process also creates initial post, tags and default category.
The setup page is done in another story #28 Add Setup.cshtml to install blog
The SetupMiddleware.cs
checks if CoreSettings.SetupDone
is true. If it is false, it will redirect current request to "/setup" page.
Shortcodes are essential to have since OLW is still primitive and many scenarios ask for some content to be pasted in, such as source code, youtube videos etc.
https://en.support.wordpress.com/shortcodes/
https://en.support.wordpress.com/category/shortcodes/
https://codex.wordpress.org/Shortcode_API
I'm using Syntaxhightlighter
This shortcode
[code language="css"]
var i = 0;
[/code]
should be translated into this
<pre class="brush: css">
your code here
</pre>
https://en.support.wordpress.com/code/posting-source-code/
http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Configuration
https://en.support.wordpress.com/code/posting-source-code/
https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Brushes-and-Themes
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
https://www.mediawiki.org/wiki/Extension:SyntaxHighlighter
C++ : cpp, c
C# : csharp, c-sharp
CSS : css
PHP : php
XML : xml, html, xhtml
Python : python, py
Java : java
JavaScript : jscript, js, javascript
Del col SortOrder from Blog_Post table
Remove property from Post class
Note: if you del a col from table but has this prop here, it'll fail "Invalid column name 'SortOrder'."
But if you have the col in db but not property in cs, it works.
Redirect
The first one can easily be done on Azure, as pointed out by this article https://blog.nicholasrogoff.com/2017/01/12/azure-app-service-force-redirect-from-http-to-https-the-easy-way/ and this is the extension being used https://www.siteextensions.net/packages/RedirectHttpToHttps/
This may be able to achieve at the registrar, here is ref https://www.name.com/support/articles/205188658-Adding-URL-Forwarding
This middleware https://github.com/aspnet/BasicMiddleware can solve both but it requires both coding and extra configuration. I don't prefer this method.
Preferred Domain Ref
https://support.google.com/webmasters/answer/44231
When I publish a post from OLW without giving a post date, the post will show up as Posted 7 hours ago.
/src
/test
DateTimeOffset should be used in place of DateTime
https://stackoverflow.com/questions/4331189/datetime-vs-datetimeoffset/14245132#14245132
https://docs.microsoft.com/en-us/dotnet/standard/datetime/choosing-between-datetime
Utc should be saved into database
https://github.com/aspnet/Identity/blob/8136fc5306df052c4afd22ad6707e845a1755307/src/Microsoft.AspNetCore.Identity.Specification.Tests/UserManagerSpecificationTests.cs
The content of the RSD file will tell where the MetaWeblog API endpoint is, for example, which accepts post requests only.
Reference: https://cyber.harvard.edu/blogs/gems/tech/rsd.html
https://msdn.microsoft.com/en-us/library/bb463260.aspx
<supportsNewCategoriesInline>Yes</supportsNewCategoriesInline>
will allow new category to be added as a single operation with newPost, without this and when you add a new post with a new category, the new category will cause a separate operation newCategory.
Note: when hooking up olw with fanray, it's important to have the single post page setup first, because olw downloads the theme by visiting the single post page.
Create a SetupController
to handle Setup.cshtml
, so that when the site is run for the first time the user can do the following
Setup is forwarded from SetupMiddleware
, see #44 Use SetupMiddleware to install blog at launch
If there is already admin user, then update <see cref="CoreSettings.SetupDone"/>
and redirect to blog index page.
The project template came with it an initial migration on the Identity tables, however it's outdated, the FanDbContextModelSnapshot shows the following code
modelBuilder.HasAnnotation("ProductVersion", "1.0.0-rc3")
after you redo this migration, it should show the following
modelBuilder.HasAnnotation("ProductVersion", "2.0.0-rtm-26452")
Figure out all the routes for the system
I've done everything except Page for Blog Service.
/Views/Blog
Robots.txt
www.robotstxt.org, right now I'm allowing crawling of all content
https://support.google.com/webmasters/answer/6062608?visit_id=1-636456036215836238-3327891123&rd=1
Get package.json ready and Task Runner Explorer ready to get resources from /client to /wwwroot. All resources are be managed with package.json.
wwwroot
By default the aspnet tables use string as the PK. Here are two ref on how to change that.
I want to eventually support login with either a username or email but not right now due to lack of time, once you add a Username field, you have to
So for right now just use email and fill the UserName column with email. In future I can use username login on other apps.
Should I add the following properties to Role table
This is done in BlogController Setup post.
https://stackoverflow.com/questions/42471866/how-to-create-roles-in-asp-net-core-and-assign-them-to-users
Based on my research there is no easy way to support multiple database vendors with migration.
Refactor commonly used operations like create and update to a base.
Need a way to get an excerpt from a body.
/Views/Shared/_Layout.cshtml
Because I'm using IDistributedCache, its API only works with byte[], I need to convert my objects to and from byte[]. A utility class serializer with help to do that.
OLW Request -> MetaWeblogMiddleWare -> Parse Request -> MetaWeblogService -> Response back
Writing a good readme.md is complex but necessary
Do the following
Readmes I like
A helpful checklist to gauge how your README is coming along:
One-liner explaining the purpose of the module
Necessary background context & links
Potentially unfamiliar terms link to informative sources
Clear, runnable example of usage
Installation instructions
Extensive API documentation
Performs cognitive funneling
Caveats and limitations mentioned up-front
Doesn't rely on images to relay critical information
License
Post, Category, Tag all need friendly URLs, thus the need to have a utility helper method to generate slugs.
Canonical url is your choice of url for a resource used for search engines, so se will display that url in the search result https://support.google.com/webmasters/answer/139066?hl=en
Permalink: will redirect you to the canonical url, it exists so that tools that depend on it will not break if canonical url is ever updated. For example, if someone posts a comment using Disqus, after that you update your post slug, the link on Disqus to your post would break if it was given the canonical url, but will be ok if it was given permalink.
Generally it's not a good idea to update slug or url format after posts are published, but if you have to do it, 1. do it ASAP, 2. SE will take some time to re-rank but it should come back.
On the single post page but no the front index page, there should be these two tags,
<meta property="og:url" content="@canonicalUrl" />
<link rel="canonical" href="@canonicalUrl" />
https://support.google.com/webmasters/answer/139066?hl=en
https://webmasters.googleblog.com/2013/04/5-common-mistakes-with-relcanonical.html
https://webmasters.googleblog.com/2011/09/pagination-with-relnext-and-relprev.html
This is also used for sharing, for example on SO https://stackoverflow.com/a/46970412/32240 will redirect you to the particular answer.
I should figure out what key words to use:
BlogPost: post (https://www.fanray.com/post/1)
Page: page (https://www.fanray.com/page/1)
uploading image and other resources needs another look
TODO: unit test file upload
https://stackoverflow.com/a/1087431/32240
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.