From fe6431508471e2219a404c95815e58cf9d67e25a Mon Sep 17 00:00:00 2001 From: Tachibana Shin <45375496+tachibana-shin@users.noreply.github.com> Date: Wed, 4 Jan 2023 20:35:26 +0700 Subject: [PATCH] first commit --- .gitignore | 6 + CHANGELOG.md | 3 + README.md | 1 + analysis_options.yaml | 30 +++ pubspec.lock | 418 ++++++++++++++++++++++++++++++++++++++++++ pubspec.yaml | 17 ++ web/FB.dart | 9 + web/index.html | 22 +++ web/main.dart | 81 ++++++++ web/styles.css | 14 ++ 10 files changed, 601 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 analysis_options.yaml create mode 100644 pubspec.lock create mode 100644 pubspec.yaml create mode 100644 web/FB.dart create mode 100644 web/index.html create mode 100644 web/main.dart create mode 100644 web/styles.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c8a157 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Files and directories created by pub. +.dart_tool/ +.packages + +# Conventional directory for build output. +build/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..effe43c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/README.md b/README.md new file mode 100644 index 0000000..07f8fc6 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +An absolute bare-bones web app. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..42215e4 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,418 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "51.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.3.1" + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.5" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.10.0" + bazel_worker: + dependency: transitive + description: + name: bazel_worker + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + build_modules: + dependency: transitive + description: + name: build_modules + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.7" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.3" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.7" + build_web_compilers: + dependency: "direct dev" + description: + name: build_web_compilers + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.7" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.4.2" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.4" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.5" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.7.0" + lints: + dependency: "direct dev" + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.14" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.3" + pointycastle: + dependency: transitive + description: + name: pointycastle + url: "https://pub.dartlang.org" + source: hosted + version: "3.6.2" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + protobuf: + dependency: transitive + description: + name: protobuf + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + scratch_space: + dependency: transitive + description: + name: scratch_space + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.11" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.18.6 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..816094b --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,17 @@ +name: embed_fbcmt +description: An absolute bare-bones web app. +version: 1.0.0 +# homepage: https://www.example.com + +environment: + sdk: '>=2.18.6 <3.0.0' + +# dependencies: +# path: ^1.7.0 +dependencies: + js: any + +dev_dependencies: + build_runner: ^2.1.4 + build_web_compilers: ^3.2.1 + lints: ^2.0.0 diff --git a/web/FB.dart b/web/FB.dart new file mode 100644 index 0000000..a805231 --- /dev/null +++ b/web/FB.dart @@ -0,0 +1,9 @@ +@JS() +library fb; + +import 'package:js/js.dart'; + +@JS() +class FB { + external static dynamic XFBML; +} \ No newline at end of file diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..2075af1 --- /dev/null +++ b/web/index.html @@ -0,0 +1,22 @@ + + + + + + + + + embed_fbcmt + + + + + +
+ +
+ +hello + + diff --git a/web/main.dart b/web/main.dart new file mode 100644 index 0000000..4acfa75 --- /dev/null +++ b/web/main.dart @@ -0,0 +1,81 @@ +import 'dart:html'; +import "dart:async"; +import 'dart:js' as js; +import "./FB.dart"; + +Future loadFBSdk([ + String? lang +]) { + lang ??= window.navigator.language.replaceFirst("-", "_"); + + final scriptEl = ScriptElement(); + + scriptEl.src = "https://connect.facebook.net/$lang/sdk.js#xfbml=1&version=v15.0&autoLogAppEvents=1"; + scriptEl.nonce = "XStSrfhG"; + + final completer = Completer(); + var loadListener; + var errorListener; + + void onLoad(Event event) { + loadListener ?.cancel(); + errorListener?.cancel(); + + completer.complete(); + } + void onError(Event event) { + loadListener ?.cancel(); + errorListener?.cancel(); + + completer.completeError(event); + } + + loadListener = scriptEl.onLoad.listen(onLoad); + errorListener = scriptEl.onError.listen(onError); + + + document.head?.children.add(scriptEl); + + return completer.future; +} + +void setConfig({ + String colorscheme = "light", + required String href, + bool lazy = false, + bool? mobile, + int num_posts = 10, + String order_by = "reverse_time"/* "time" | "reverse_time" */, + int width = 550 +}) { + + final commentsEl = querySelector("#comments"); + + if (commentsEl == null) { + throw Exception("#comments not exists"); + } +// data-href="" data-width="" data-numposts="5" + commentsEl.dataset["colorscheme"] = colorscheme; + commentsEl.dataset["href"] = href; + commentsEl.dataset["lazy"] = lazy ? "true" : "false"; + if (mobile is bool) + commentsEl.dataset["mobile"] = mobile ? "true" : "false"; + commentsEl.dataset["numposts"] = num_posts.toString(); + commentsEl.dataset["order-by"] = order_by; + commentsEl.dataset["width"] = width.toString(); + + if (js.context["FB"] != null) + FB.XFBML.parse(); +} + +void main() async { + await loadFBSdk().catchError((e) { + print("load FB SDK failied"); + throw Exception(e); + }); + + print("FB SDK loaded"); + final href =("https://developers.facebook.com/docs/plugins/comments#configurator"); + + setConfig(href: "https://googe.com", colorscheme: "dark"); +} diff --git a/web/styles.css b/web/styles.css new file mode 100644 index 0000000..cc035c9 --- /dev/null +++ b/web/styles.css @@ -0,0 +1,14 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto); + +html, body { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + font-family: 'Roboto', sans-serif; +} + +#output { + padding: 20px; + text-align: center; +}