Skip to content

access bootstrap files from web #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/css.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class CSS {
// The bootstrap css file
final String cssFilePath = '/packages/bootstrap/css/bootstrap.css';

final String cssHeader =
'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css';

final String theme =
'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css';

final String jsScript =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keerti, fyi, I don't think any of the bits of bootstrap that dartdoc is using requires the JS file, just the main css file and the theme one.

'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js';

String getCssName() => 'bootstrap.css';

String getCssContent() {
Expand All @@ -20,4 +29,5 @@ class CSS {
String text = cssFile.readAsStringSync(encoding: ASCII);
return text;
}

}
10 changes: 6 additions & 4 deletions lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ body {
generatePackage();
package.libraries.forEach((lib) => generateLibrary(lib));
// copy the css resource into 'out'
File f = joinFile(new Directory(out.path), [css.getCssName()]);
f.writeAsStringSync(css.getCssContent());
// File f = joinFile(new Directory(out.path), [css.getCssName()]);
// f.writeAsStringSync(css.getCssContent());
if (url != null) {
generateSiteMap();
}
Expand All @@ -59,7 +59,8 @@ body {

html.start(
title: 'Package ${packageName}',
cssRef: css.getCssName(),
cssRef: css.cssHeader,
theme: css.theme,
inlineStyle: bootstrapOverrides);
html.generateHeader();
html.startTag('div', attributes: "class='container'", newLine: false);
Expand Down Expand Up @@ -102,7 +103,8 @@ body {
html = new HtmlHelper();
html.start(
title: 'Library ${library.name}',
cssRef: css.getCssName(),
cssRef: css.cssHeader,
theme: css.theme,
inlineStyle: bootstrapOverrides);

html.generateHeader();
Expand Down
8 changes: 7 additions & 1 deletion lib/src/html_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HtmlHelper {
endTag();
}

void start({String title, String cssRef, String inlineStyle}) {
void start({String title, String cssRef, String theme, String jsScript, String inlineStyle}) {
startTag('html', newLine: false);
writeln();
startTag('head');
Expand All @@ -43,6 +43,12 @@ class HtmlHelper {
if (cssRef != null) {
writeln('<link href="${cssRef}" rel="stylesheet" media="screen">');
}
if (theme != null) {
writeln('<link href="${theme}" rel="stylesheet">');
}
if (jsScript != null) {
writeln('<script src="${jsScript}"></script>');
}
if (inlineStyle != null) {
startTag('style');
writeln(inlineStyle);
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
yaml: any

dev_dependencies:
http: any
unittest: any

executables:
Expand Down
3 changes: 3 additions & 0 deletions test/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

library dartdoc.all_tests;

import 'css_test.dart' as css_tests;
import 'template_test.dart' as template_tests;


main() {
css_tests.tests();
template_tests.tests();
}
38 changes: 38 additions & 0 deletions test/css_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

library dartdoc.css_test;

import 'package:http/http.dart' as http;
import 'package:unittest/unittest.dart';

import '../lib/src/css.dart';

tests() {
group('check bootstrap', () {
CSS css = new CSS();

test('css stylesheet url exists', () {
var url = css.cssHeader;
http.get(url).then((response) {
expect(response.statusCode, 200);
});
});

test('theme stylesheet url exists', () {
var url = css.theme;
http.get(url).then((response) {
expect(response.statusCode, 200);
});
});

test('js script exists', () {
var url = css.jsScript;
http.get(url).then((response) {
expect(response.statusCode, 200);
});
});

});
}