224 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			224 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Microsoft.AspNetCore.Authorization;
 | |
| using Microsoft.AspNetCore.Mvc;
 | |
| using WeatherForecast.Models;
 | |
| using WeatherForecast.Models.Abstractions;
 | |
| using WeatherForecast.Models.Pages;
 | |
| using WeatherForecast.Models.PageSections;
 | |
| using WeatherForecast.Models.Responses;
 | |
| 
 | |
| namespace WeatherForecast.Controllers;
 | |
| 
 | |
| /// <summary>
 | |
| /// 
 | |
| /// </summary>
 | |
| [ApiController]
 | |
| [AllowAnonymous]
 | |
| [Route("api/[controller]")]
 | |
| public class StaticContentController : ControllerBase {
 | |
| 
 | |
|   private readonly ILogger<StaticContentController> _logger;
 | |
| 
 | |
|   /// <summary>
 | |
|   /// 
 | |
|   /// </summary>
 | |
|   /// <param name="logger"></param>
 | |
|   public StaticContentController(
 | |
|     ILogger<StaticContentController> logger
 | |
|   ) {
 | |
|     _logger = logger;
 | |
|   }
 | |
| 
 | |
|   /// <summary>
 | |
|   /// 
 | |
|   /// </summary>
 | |
|   /// <returns></returns>
 | |
|   [HttpGet]
 | |
|   public IActionResult Get([FromQuery] string? locale = "en-US") {
 | |
| 
 | |
|     var routes = new List<RouteModel> {
 | |
|       new RouteModel ("/", "Home"),
 | |
|       new RouteModel ("/home", "Home")
 | |
|     };
 | |
| 
 | |
|     var shopRoute = new RouteModel("/shop",
 | |
|       new List<RouteModel> {
 | |
|       new RouteModel ("", "ShopCatalog"),
 | |
|       new RouteModel (":page", "ShopCatalog"),
 | |
|         new RouteModel (":page", new List<RouteModel> {
 | |
|             new RouteModel (":slug", "ShopItem")
 | |
|           })
 | |
|     });
 | |
| 
 | |
|     var blogRoute = new RouteModel("/blog",
 | |
|       new List<RouteModel> {
 | |
|       new RouteModel ("", "BlogCatalog"),
 | |
|       new RouteModel (":page", "BlogCatalog"),
 | |
|         new RouteModel (":page", new List<RouteModel> {
 | |
|             new RouteModel (":slug", "BlogItem")
 | |
|           })
 | |
|     });
 | |
| 
 | |
|     routes.Add(shopRoute);
 | |
|     routes.Add(blogRoute);
 | |
| 
 | |
|     var demoRoutes = new List<RouteModel> {
 | |
|       new RouteModel ("/counter", "Counter"),
 | |
|       new RouteModel ("/fetch-data", new List<RouteModel> {
 | |
|           new RouteModel ("", "FetchData"),
 | |
|           new RouteModel (":startDateIndex", "FetchData")
 | |
|         })
 | |
|       };
 | |
| 
 | |
|     routes = routes.Concat(demoRoutes).ToList();
 | |
| 
 | |
|     var adminRoutes = new List<RouteModel> {
 | |
|       new RouteModel ("/admin", "AdminHome")
 | |
|     };
 | |
| 
 | |
|     var serviceRoutes = new List<RouteModel> {
 | |
|       new RouteModel ("/signin", "Signin"),
 | |
|       new RouteModel ("/signup", "Signup"),
 | |
|       new RouteModel ("*",  "Error")
 | |
|     };
 | |
| 
 | |
|     var topMenu = new List<MenuItemModel> {
 | |
|       new MenuItemModel ("Home", "/"),
 | |
|       new MenuItemModel ("Shop", "/shop"),
 | |
|       new MenuItemModel ("Blog", "/blog"),
 | |
|       new MenuItemModel ("Signin", "/signin"),
 | |
|       new MenuItemModel ("Signout", "/signout")
 | |
|     };
 | |
| 
 | |
|     var sideMenu = new List<MenuItemModel> {
 | |
|       new MenuItemModel ("alert-triangle", "Home", "/admin"),
 | |
|       new MenuItemModel ("activity", "Page", new List<MenuItemModel> { 
 | |
|         new MenuItemModel ("activity", "Page-1", "Page-1"),
 | |
|         new MenuItemModel ("activity", "Page-2", "Page-2"),
 | |
|         new MenuItemModel ("activity", "Page-3", "Page-3")
 | |
|       }),
 | |
|       new MenuItemModel ("Counter", "/counter"),
 | |
|       new MenuItemModel ("Fetch data", "/fetch-data")
 | |
|     };
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     var blogItems = new List<BlogItemModel>();
 | |
|     for (int i = 0; i < 3; i++) {
 | |
|       var blogItemModel = new BlogItemModel {
 | |
|         Id = Guid.NewGuid(),
 | |
|         Slug = "blog-post-title",
 | |
|         Image = new ImageModel { Src = "https://dummyimage.com/600x350/ced4da/6c757d", Alt = "..." },
 | |
|         Badge = "news",
 | |
|         Title = "Blog post title",
 | |
|         ShortText = "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad...",
 | |
|         Text = "",
 | |
|         Author = new AuthorModel {
 | |
|           Id = Guid.NewGuid(),
 | |
|           Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." },
 | |
|           NickName = "Admin"
 | |
|         },
 | |
|         Created = DateTime.UtcNow,
 | |
|         Tags = new List<string> { "react", "redux", "webapi" },
 | |
| 
 | |
|         ReadTime = 10,
 | |
|         Likes = 200,
 | |
|       };
 | |
| 
 | |
|       blogItems.Add(blogItemModel);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     var homePage = new HomePageModel {
 | |
|       TitleSection = new TitleSectionModel {
 | |
|         Title = "Hello, World! by C#",
 | |
|         Text = @"
 | |
|         <p>Welcome to your new single-page application, built with:</p>
 | |
|         <ul>
 | |
|           <li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li>
 | |
|           <li><a href='https://facebook.github.io/react/'>React</a> and <a href='https://redux.js.org/'>Redux</a> for client-side code</li>
 | |
|           <li><a href='https://getbootstrap.com/'>Bootstrap</a>, <a href='https://reactstrap.github.io/?path=/story/home-installation--page'>Reactstrap</a> and <a href=\""https://feathericons.com/\"">Feather icons</a> for layout and styling</li>
 | |
|         </ul>",
 | |
|         Image = new ImageModel { Src = "https://dummyimage.com/600x400/343a40/6c757d", Alt = "..." },
 | |
|         PrimaryLink = new MenuItemModel("Get Started", "#features"),
 | |
|         SecondaryLink = new MenuItemModel("Learn More", "#!")
 | |
|       },
 | |
| 
 | |
|       FeaturesSection = new FeaturesSectionModel {
 | |
|         Title = "To help you get started, we have also set up:",
 | |
|         Items = new List<FeatureModel> {
 | |
|           new FeatureModel {
 | |
|             Icon = "navigation",
 | |
|             Title = "Client-side navigation",
 | |
|             Text = "For example, click <em>Counter</em> then <em>Back</em> to return here."
 | |
|           },
 | |
|           new FeatureModel {
 | |
|             Icon = "server",
 | |
|             Title = "Development server integration",
 | |
|             Text = "In development mode, the development server from <code>create-react-app</code> runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file."
 | |
|           },
 | |
|           new FeatureModel {
 | |
|             Icon = "terminal",
 | |
|             Title = "Efficient production builds",
 | |
|             Text = "In production mode, development-time features are disabled, and your <code>dotnet publish</code> configuration produces minified, efficiently bundled JavaScript files."
 | |
|           }
 | |
|         }
 | |
|       },
 | |
|       TestimonialsSection = new TestimonialsSectionModel {
 | |
|         Items = new List<TestimonialModel> {
 | |
|           new TestimonialModel {
 | |
|             Text = "The <code>ClientApp</code> subdirectory is a standard React application based on the <code>create-react-app</code> template. If you open a command prompt in that directory, you can run <code>yarn</code> commands such as <code>yarn test</code> or <code>yarn install</code>.",
 | |
|             Reviewer = new ReviewerModel {
 | |
|               Image = new ImageModel { Src = "https://dummyimage.com/40x40/ced4da/6c757d", Alt = "..." },
 | |
|               FullName = "Admin",
 | |
|               Position = "CEO, MAKS-IT"
 | |
|             }
 | |
|           }
 | |
|         }
 | |
|       },
 | |
|       FeaturedBlogsSection = new FeaturedBologsSectionModel {
 | |
|         Title = "From our blog",
 | |
|         Items = blogItems
 | |
|       },
 | |
| 
 | |
|       CallToActionSection = new CallToActionSectionModel {
 | |
|         Title = "New products, delivered to you.",
 | |
|         Text = "Sign up for our newsletter for the latest updates.",
 | |
|         PrivacyDisclaimer = "We care about privacy, and will never share your data.",
 | |
|         Email = new FormItemModel {
 | |
|           PlaceHolder = "Email address...",
 | |
|           Title = "Sign up"
 | |
|         }
 | |
|       }
 | |
|     };
 | |
| 
 | |
|     var shopCatalogPage = new ShopCatalogPageModel {
 | |
|       TitleSection = new TitleSectionModel {
 | |
|         Title = "Shop in style",
 | |
|         Text = "With this shop hompeage template"
 | |
|       }
 | |
|     };
 | |
| 
 | |
|     var blogCatalogPage = new BlogCatalogPageModel {
 | |
|       TitleSection = new TitleSectionModel {
 | |
|         Title = "Welcome to Blog Home!",
 | |
|         Text = "A Bootstrap 5 starter layout for your next blog homepage"
 | |
|       }
 | |
|     };
 | |
| 
 | |
|     return Ok(new GetStaticContentResponseModel {
 | |
|       SiteName = "MAKS-IT",
 | |
| 
 | |
|       Routes = routes,
 | |
|       AdminRoutes = adminRoutes,
 | |
|       ServiceRoutes = serviceRoutes,
 | |
| 
 | |
|       TopMenu = topMenu,
 | |
|       SideMenu = sideMenu,
 | |
|       HomePage = homePage,
 | |
|       ShopCatalog = shopCatalogPage,
 | |
|       BlogCatalog = blogCatalogPage
 | |
|     });
 | |
|   }
 | |
| }
 |