Code Monkey home page Code Monkey logo

fanray's People

Contributors

flyznex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fanray's Issues

Remove SortOrder from Post table

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.

Update README.md files

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

fanray

fanray2

fanray3

Install blog with SetupController

Intro

Create a SetupController to handle Setup.cshtml, so that when the site is run for the first time the user can do the following

  • Create admin user
  • Sign-in the user
  • Create blog settings
  • Create initial blog post, tags and default category

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.

Make use of canonical url and permalink

Canonical url vs permalink

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.

Canonical url

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

Permalink

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)

Routes for the blog

Figure out all the routes for the system

  • OLW endpoint
  • MVC routes
  • Business object urls

Package.json for /client

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

  • css (gen from scss folder, built and min-ed)
  • js (syntaxhighlighter.js)
  • lib (copied from node_modules)
    • bootstrap
    • font-awesome
    • jquery
    • jquery-validation
  • favicon.ico
  • wlwmanifest.xml

Disqus support

Requirements

  • Add disqus
  • Add shortname to blog setup and blog settings
  • Check condition if it is disqus being used, if not, hide the js snippets (_Layout, _Comments, _PostInfo)
  • Tweak css to make it fit on the post page
  • Make sure when post comment is disabled, disable the comment (this seems not doable)
  • Comment count

Questions

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}"

Key Config Parameters

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-

References

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&amp;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

Finalize EF Migration strategy

Dropping SQLite support

A hard decision but one worth making. I've supported Sqlite throughout v1 alpha and betas, the benefits of using Sqlite include:

  1. out of box user can just run the app, there is no db requirement whatsoever on users part, it just works.
  2. it works out of box on all the OSes, Win, Linux and Mac.
  3. for user running just a personal blog sqlite is sufficient, no need to spend extra on sql server.

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:

  1. easy upgrade, user can just run the new version of the app and all new db changes are applied through migration automatically
  2. if other decides to add a new app or plugin, they can add their migrations along, user running that code base will automatically have the necessary db tables etc ready for the new app or plugins.
  3. one less db vendor to support; sqlite migration has limitations, e.g. rename a column, which I don't have to live with

How to support multiple DbContext

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.

Add Fan.Tests xUnit project and add DataTestHelper to assist In Memory Db testing

Add Fan.Tests xUnit project to /test and the necessary nuget packages

  • Microsoft.Data.Sqlite
  • Microsoft.EntityFrameworkCore.Sqlite
  • Microsoft.EntityFrameworkCore.InMemory

Add DataTestHelper class

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.

Refactor MetaWeblog from Fan.Web into Fan.Blogs

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.

Minor issues to fix for v1.0.0

  • Update footer
  • Clean up appsettings
  • Move favicon.ico, robots.txt and wlwmanifest.xml to client folder and update package.json
  • Remove bundleconfig.json
  • Update styles
  • Initial content
  • Update favicon.ico

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

Create Validators and integrate Validation Messages with FanException

FanException

When we throw our own exception, we may want to carry with it the validation messages.

Validators for Post and Taxonomy

When user creates a Post, the post title

  • cannot be empty
  • cannot exceed 256 chars

When user creates a Category, the category title

  • cannot be empty
  • cannot exceed 24 chars
  • must be unique with case insensitive

I need validtor for each of the two classes.

Update the initial EF migration

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")

http and www redirect

Redirect

  1. http -> https
  2. root domain -> www

http -> https

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/

root domain -> www

This may be able to achieve at the registrar, here is ref https://www.name.com/support/articles/205188658-Adding-URL-Forwarding

BasicMiddleware

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

Develop BlogService

  • IBlogService
  • BlogService
  • Tests

I've done everything except Page for Blog Service.

_Layout.cshtml

/Views/Shared/_Layout.cshtml

  • css, js for dev and non-dev environments
  • html structure
    • nav
    • container
    • footer

Sqlite Support

By default

  • Use Sqlite in Development
  • Use Sql Server in Production

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
}

Implement Logging

Shortcodes support

Overview

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

SourceCodeShortCode

I'm using Syntaxhightlighter

Translation

This shortcode

[code language="css"]
var i = 0;
[/code]

should be translated into this

<pre class="brush: css">
your code here
</pre>

Configuration

https://en.support.wordpress.com/code/posting-source-code/
http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Configuration

Languages Supported

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

YouTubeShortCode

Blog Views

/Views/Blog

  • Index
  • Post
  • Category
  • Tag
  • Rsd

Asp.net Identity update

Use int PK for all tables (done)

By default the aspnet tables use string as the PK. Here are two ref on how to change that.

Rename table names (done)

  • Rename aspnet table to "Fan_" and use singular table name instead of plural such as
    AspNetRoles -> Fan_Roles
  • Add "Blog_" prefix to other tables.

Decide on name and email when sign up and login (not right now)

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

  • Validate username (a-z,0-9 that sort thing)
  • Verify if incoming username is email or not, if it's email search use by it and get the real username

So for right now just use email and fill the UserName column with email. In future I can use username login on other apps.

Add default "Admin" Role during blog setup (done)

Should I add the following properties to Role table

  • IsSystemRole
  • Description

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

Decide whether to keep Migrations as part of my repo (done)

Based on my research there is no easy way to support multiple database vendors with migration.

Revamp settings into one in each functional area

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.

Use SetupMiddleware to install blog at launch

Intro

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 middleware

The SetupMiddleware.cs checks if CoreSettings.SetupDone is true. If it is false, it will redirect current request to "/setup" page.

RSD and wlwmanifest for MetaWeblog

Rsd

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

wlwmanifest.xml

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.