:)
This commit is contained in:
commit
77af2aa8e4
15 changed files with 330 additions and 0 deletions
112
.gitignore
vendored
Normal file
112
.gitignore
vendored
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
.idea/workspace.xml
|
||||||
|
.idea/tasks.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/vcs.xml
|
||||||
|
.idea/jsLibraryMappings.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
.idea/dataSources.ids
|
||||||
|
.idea/dataSources.xml
|
||||||
|
.idea/dataSources.local.xml
|
||||||
|
.idea/sqlDataSources.xml
|
||||||
|
.idea/dynamic.xml
|
||||||
|
.idea/uiDesigner.xml
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
.idea/gradle.xml
|
||||||
|
.idea/libraries
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
.idea/mongoSettings.xml
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
### Dart template
|
||||||
|
# See https://www.dartlang.org/tools/private-files.html
|
||||||
|
|
||||||
|
# Files and directories created by pub
|
||||||
|
.buildlog
|
||||||
|
.packages
|
||||||
|
.project
|
||||||
|
.pub/
|
||||||
|
build/
|
||||||
|
**/packages/
|
||||||
|
|
||||||
|
# Files created by dart2js
|
||||||
|
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||||
|
# rules if you intend to use dart2js directly
|
||||||
|
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||||
|
# differentiate from explicit Javascript files)
|
||||||
|
*.dart.js
|
||||||
|
*.part.js
|
||||||
|
*.js.deps
|
||||||
|
*.js.map
|
||||||
|
*.info.json
|
||||||
|
|
||||||
|
# Directory created by dartdoc
|
||||||
|
doc/api/
|
||||||
|
|
||||||
|
# Don't commit pubspec lock file
|
||||||
|
# (Library packages only! Remove pattern if developing an application package)
|
||||||
|
pubspec.lock
|
||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
### Dart template
|
||||||
|
# See https://www.dartlang.org/tools/private-files.html
|
||||||
|
|
||||||
|
# Files and directories created by pub
|
||||||
|
|
||||||
|
# Files created by dart2js
|
||||||
|
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||||
|
# rules if you intend to use dart2js directly
|
||||||
|
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||||
|
# differentiate from explicit Javascript files)
|
||||||
|
|
||||||
|
# Directory created by dartdoc
|
||||||
|
|
||||||
|
# Don't commit pubspec lock file
|
||||||
|
# (Library packages only! Remove pattern if developing an application package)
|
6
.idea/runConfigurations/Start_Server.xml
Normal file
6
.idea/runConfigurations/Start_Server.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Start Server" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
|
||||||
|
<option name="filePath" value="$PROJECT_DIR$/bin/server.dart" />
|
||||||
|
<method />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 angel-dart
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
20
bin/server.dart
Normal file
20
bin/server.dart
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:angel/angel.dart';
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
|
||||||
|
main() async {
|
||||||
|
Angel app = createServer();
|
||||||
|
|
||||||
|
runZoned(() async {
|
||||||
|
await app.startServer(
|
||||||
|
new InternetAddress(app.properties['host']), app.properties['port']);
|
||||||
|
print("Angel server listening on ${app.httpServer.address.host}:${app
|
||||||
|
.httpServer.port}");
|
||||||
|
}, onError: (error, [StackTrace stackTrace]) {
|
||||||
|
stderr.writeln("Unhandled error occurred: $error");
|
||||||
|
if (stackTrace != null) {
|
||||||
|
stderr.writeln(stackTrace);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
2
config/default.yaml
Normal file
2
config/default.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Default server configuration.
|
||||||
|
host: 127.0.0.1
|
2
config/development.yaml
Normal file
2
config/development.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Development-only server configuration.
|
||||||
|
port: 3000
|
2
config/production.yaml
Normal file
2
config/production.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Production-only server configuration
|
||||||
|
port: 80
|
14
lib/angel.dart
Normal file
14
lib/angel.dart
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/// Your very own web application!
|
||||||
|
library angel;
|
||||||
|
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'src/config/config.dart' show configureServer;
|
||||||
|
|
||||||
|
/// Creates and configures the server instance.
|
||||||
|
Angel createServer() {
|
||||||
|
Angel app = new Angel();
|
||||||
|
|
||||||
|
app.configure(configureServer);
|
||||||
|
|
||||||
|
return app;
|
||||||
|
}
|
14
lib/src/config/config.dart
Normal file
14
lib/src/config/config.dart
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/// Configuration for this Angel instance.
|
||||||
|
library angel.config;
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:angel_configuration/angel_configuration.dart';
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'package:angel_mustache/angel_mustache.dart';
|
||||||
|
import 'routes.dart';
|
||||||
|
|
||||||
|
configureServer(Angel app) {
|
||||||
|
app.configure(loadConfigurationFile());
|
||||||
|
app.configure(mustache(new Directory('views')));
|
||||||
|
app.configure(configureRoutes);
|
||||||
|
}
|
20
lib/src/config/routes.dart
Normal file
20
lib/src/config/routes.dart
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/// This app's route configuration.
|
||||||
|
library angel.routes;
|
||||||
|
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'package:angel_static/angel_static.dart';
|
||||||
|
|
||||||
|
/// Put your app routes here!
|
||||||
|
configureRoutes(Angel app) {
|
||||||
|
app.get('/', (req, ResponseContext res) => res.render('hello'));
|
||||||
|
app.get('*', serveStatic());
|
||||||
|
|
||||||
|
app.on404 = (RequestContext req, ResponseContext res) async {
|
||||||
|
res.willCloseItself = true;
|
||||||
|
res.status(404);
|
||||||
|
res.header('Content-Type', 'text/html');
|
||||||
|
res.underlyingResponse.write(
|
||||||
|
await app.viewGenerator('404', {'path': req.path}));
|
||||||
|
await res.underlyingResponse.close();
|
||||||
|
};
|
||||||
|
}
|
14
pubspec.yaml
Normal file
14
pubspec.yaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: angel
|
||||||
|
description: An easily-extensible web server framework in Dart.
|
||||||
|
version: 0.0.0-dev.0
|
||||||
|
author: thosakwe <thosakwe@gmail.com>
|
||||||
|
homepage: https://github.com/angel-dart/angel
|
||||||
|
dependencies:
|
||||||
|
angel_configuration: ">= 1.0.0-dev < 2.0.0"
|
||||||
|
angel_framework: ">=0.0.0-dev < 0.1.0"
|
||||||
|
angel_mustache: ">= 1.0.0-dev < 2.0.0"
|
||||||
|
angel_static: ">= 1.0.0-beta.1 < 1.1.0"
|
||||||
|
json_god: ">= 1.0.0 < 2.0.0"
|
||||||
|
dev_dependencies:
|
||||||
|
http: ">= 0.11.3 < 0.12.0"
|
||||||
|
test: ">= 0.12.13 < 0.13.0"
|
50
views/404.mustache
Normal file
50
views/404.mustache
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>404 Not Found</title>
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: table;
|
||||||
|
font-weight: 100;
|
||||||
|
font-family: 'Lato', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
text-align: center;
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 96px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 32px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="content">
|
||||||
|
<div class="title">404 Not Found</div>
|
||||||
|
<div class="subtitle">No file was found at "{{path}}".</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
45
views/hello.mustache
Normal file
45
views/hello.mustache
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Angel</title>
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: table;
|
||||||
|
font-weight: 100;
|
||||||
|
font-family: 'Lato', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
text-align: center;
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
text-align: center;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 96px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="content">
|
||||||
|
<div class="title">Angel</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
2
web/robots.txt
Normal file
2
web/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /admin
|
Loading…
Reference in a new issue