Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 960f32b
Showing
49 changed files
with
2,374 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
WEB_DESCRIPTION="Material 4 Dart / Content" | |||
WEB_PACKAGE="m4d_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
Copyright (c) 2018, Michael Mitterer (office@mikemitterer.at), | |||
IT-Consulting and Development Limited. | |||
|
|||
All Rights Reserved. | |||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 | |||
|
|||
Redistribution and use in source and binary forms, with or without | |||
modification, are permitted provided that the following conditions are met: | |||
* Redistributions of source code must retain the above copyright | |||
notice, this list of conditions and the following disclaimer. | |||
* Redistributions in binary form must reproduce the above copyright | |||
notice, this list of conditions and the following disclaimer in the | |||
documentation and/or other materials provided with the distribution. | |||
* Neither the name of the Michael Mitterer, IT-Consulting | |||
and Development Limited, Austrian Branch, nor the | |||
names of its contributors may be used to endorse or promote products | |||
derived from this software without specific prior written permission. | |||
|
|||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
DISCLAIMED. IN NO EVENT SHALL Michael Mitterer, | |||
IT-Consulting and Development Limited, Austrian Branch, BE LIABLE FOR ANY | |||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
# Material 4 Dart - Content / Include | |||
|
|||
## Examples | |||
> [GitHub](https://github.com/MikeMitterer/m4d_content) | |||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
analyzer: | |||
# exclude: | |||
# - path/to/excluded/files/** | |||
|
|||
# Lint rules and documentation, see http://dart-lang.github.io/linter/lints | |||
linter: | |||
rules: | |||
- cancel_subscriptions | |||
- hash_and_equals | |||
- iterable_contains_unrelated_type | |||
- list_remove_unrelated_type | |||
- test_types_in_equals | |||
- unrelated_type_equality_checks | |||
- valid_regexps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
pipeline { | |||
agent { | |||
label 'linux' | |||
} | |||
stages { | |||
stage('Preparation') { | |||
steps { | |||
timeout(time: 15, unit: 'MINUTES') { | |||
ansiColor('xterm') { | |||
sh 'pub update' | |||
} | |||
} | |||
|
|||
} | |||
} | |||
stage('Analyze') { | |||
steps { | |||
ansiColor('xterm') { | |||
sh 'dartanalyzer lib/' | |||
// sh 'dartanalyzer test/' | |||
} | |||
} | |||
} | |||
/* | |||
stage('Test') { | |||
steps { | |||
ansiColor('xterm') { | |||
sh 'pub run test test -p chrome' | |||
} | |||
} | |||
} | |||
*/ | |||
stage('Deploy samples') { | |||
steps { | |||
timeout(time: 30, unit: 'MINUTES') { | |||
ansiColor('xterm') { | |||
sh 'deploySamples.sh --prepare' | |||
sh 'deploySamples.sh --update' | |||
sh 'deploySamples.sh --deploy --release' | |||
sh 'deploySamples.sh --publish --force' | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
# Browser-Based project - Test chrome by default. | |||
platforms: [ chrome ] | |||
|
|||
paths: | |||
- test | |||
|
|||
#define_platforms: | |||
# # This identifier is used to select the platform with the --platform flag. | |||
# chromium: | |||
# # A human-friendly name for the platform. | |||
# name: Chromium | |||
# | |||
# # The identifier for the platform that this is based on. | |||
# extends: chrome | |||
# | |||
# # Settings for the new child platform. | |||
# settings: | |||
# executable: | |||
# linux: chromium-browser | |||
# mac_os: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome | |||
# | |||
# # Funkt nicht: --headless | |||
# # https://github.com/dart-lang/test/issues/730 | |||
# arguments: --window-position=5000,5000 --window-size=1,1 --disable-gpu | |||
# | |||
|
|||
override_platforms: | |||
chrome: | |||
settings: | |||
headless: false | |||
# Funkt nicht: --headless | |||
# https://github.com/dart-lang/test/issues/730 | |||
#arguments: --window-position=5000,5000 --window-size=1,1 --disable-gpu | |||
arguments: --window-position=10,0 --window-size=1000,800 | |||
|
|||
on_os: | |||
linux: | |||
override_platforms: | |||
chrome: | |||
# The settings to override for this platform. | |||
settings: | |||
executable: chromium-browser | |||
arguments: --window-position=1500,1000 --window-size=2,2 --disable-gpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
/* | |||
* Copyright (c) 2015, Michael Mitterer (office@mikemitterer.at), | |||
* IT-Consulting and Development Limited. | |||
* | |||
* All Rights Reserved. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
part of m4d_content; | |||
|
|||
abstract class MaterialController { | |||
/// [iocContainer] will be set after {ViewFactory} receives the {onLoadEnd} Event | |||
ioc.IOCContainer iocContainer; | |||
|
|||
/// [loaded] is called after [ViewFactory] received the onLoadEnd-Event | |||
/// | |||
/// At this point the Template is already rendered | |||
void loaded(final RouteEnterEvent event); | |||
|
|||
/// Called before the next controller is loaded | |||
void unload() {} | |||
} | |||
|
|||
class DummyController extends MaterialController { | |||
final Logger _logger = new Logger('mdlapplication.DummyController'); | |||
|
|||
@override | |||
void loaded(final RouteEnterEvent event) { | |||
_logger.info("View loaded! (Route: ${event.route})"); | |||
} | |||
|
|||
@override | |||
void unload() { | |||
_logger.info("Unload Controller..."); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,119 @@ | |||
/* | |||
* Copyright (c) 2015, Michael Mitterer (office@mikemitterer.at), | |||
* IT-Consulting and Development Limited. | |||
* | |||
* All Rights Reserved. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
part of m4d_content; | |||
|
|||
/** | |||
* Loads additional "views" (html-Page) in SPA-Application | |||
* | |||
* Sample: | |||
* configRouter() { | |||
* final Router router = new Router(useFragment: true); | |||
* final ViewFactory view = new ViewFactory(); | |||
* | |||
* router.root | |||
* ..addRoute(name: 'typography', path: '/typography', | |||
* enter: view("views/typography.html", new DemoController())) | |||
* | |||
* ..addRoute(name: 'home', defaultRoute: true, path: '/', | |||
* enter: view("views/home.html" ,new DemoController())) | |||
* | |||
* ; | |||
* | |||
* router.listen(); | |||
* } | |||
* | |||
* Until 2017.11.09 ViewFactory was "injectable". This should not be necessary. | |||
* Changing the ViewFactory to a individual version should be very easy without DI. | |||
* See example from above | |||
*/ | |||
class ViewFactory { | |||
final Logger _logger = new Logger('mdlremote.ViewFactory'); | |||
|
|||
MaterialController _previousController; | |||
|
|||
RouteEnterCallback call(final String url, final MaterialController controller, { final String selector: "#main"}) { | |||
return (final RouteEvent event) => _enterHandler(event, url, controller, selector); | |||
} | |||
|
|||
// void call(final String url, final MaterialController controller, { final String selector: "#main"}) { | |||
// _enterHandler( url, controller, selector); | |||
// } | |||
|
|||
//- private ----------------------------------------------------------------------------------- | |||
|
|||
void _enterHandler(final RouteEvent event, final String url, | |||
final MaterialController controller, final String selector) { | |||
|
|||
//Validate.notNull(event); | |||
Validate.notNull(url); | |||
Validate.notNull(controller); | |||
Validate.notBlank(selector); | |||
|
|||
final Stopwatch stopwatch = new Stopwatch(); | |||
final dom.HttpRequest request = new dom.HttpRequest(); | |||
final dom.Element contentElement = dom.querySelector(selector); | |||
|
|||
if(contentElement == null) { | |||
_logger.severe('Please add <div id="$selector" class="mdl-content">Loading...</div> to your index.html'); | |||
return; | |||
} | |||
|
|||
if(_previousController != null) { | |||
_previousController.unload(); | |||
} | |||
_previousController = controller; | |||
|
|||
request.open("GET", url); | |||
request.onLoadEnd.listen((final dom.ProgressEvent progressEvent) { | |||
//_logger.info('Request complete ${request.responseText}, Status: ${request.readyState}'); | |||
|
|||
if (request.readyState == dom.HttpRequest.DONE) { | |||
|
|||
final String content = sanitizeResponseText(request.responseText); | |||
final MaterialContent main = MaterialContent.widget(contentElement); | |||
|
|||
|
|||
// if(controller is ScopeAware) { | |||
// // If you have observable-Properties in your Controller it must be | |||
// // marked as [@mdl.Model] | |||
// // TODO: Check controller if it has a Annotation | |||
// main.scope = (controller as ScopeAware).scope; | |||
// } | |||
// else { | |||
// main.resetScope(); | |||
// } | |||
|
|||
main.render(content).then( (_) { | |||
|
|||
// TODO: Rename injector to iocContainer | |||
controller.iocContainer = main.injector; | |||
controller.loaded(event); | |||
|
|||
stopwatch.stop(); | |||
_logger.info("Page load and rendering took ${stopwatch.elapsedMilliseconds}ms"); | |||
}); | |||
} | |||
}); | |||
|
|||
stopwatch.start(); | |||
request.send(); | |||
} | |||
|
|||
} |
Oops, something went wrong.