Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Getting Dropzone back on track

Matias Meno enyo

🤓
Getting Dropzone back on track
View GitHub Profile
View base.yaml
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
View deploy.yaml
jobs:
build:
# ...
test:
# ...
deploy:
# Only run if merged to main.
if: github.ref == 'refs/heads/main'
# Only deploy if all tests passed.
View build.yaml
jobs:
build:
# We're running on ubuntu-latest, nothing special
runs-on: ubuntu-latest
steps:
# As usual, we simply checkout the project
- name: Checkout
uses: actions/checkout@v2
# This action is provided by Cypress. It installs node and the NPM
View test.yaml
jobs:
build:
# Everything from the last section
test:
# We depend on the build step for this.
needs: build
timeout-minutes: 15
runs-on: ubuntu-latest
# We need to use the cypress container here, that includes chrome and
View grpc_client.dart
/// A channel that the gRPC libray communicates over.
/// This is provided by the gRPC library.
final channel = GrpcWebClientChannel.xhr(Uri.parse('https://your.api.url:8080'));
/// The class [AccountServiceClient] is generated by the gRPC library from
/// your `.proto` definition.
final client = AccountServiceClient(channel);
Future<void> changePassword() async {
/// The message you want to send to the API. It's also generated from your
View grpc_server_stub.dart
class AccountService extends AccountServiceBase {
@override
Future<Empty> sendEmailVerification(ServiceCall call, VerificationRequest request) {
// TODO: implement sendEmailVerification
throw UnimplementedError();
}
@override
Future<User> signInWithPassword(ServiceCall call, PasswordSignInRequest request) {
// TODO: implement signInWithPassword
View account.proto
syntax = "proto3";
package dropzone.public_account;
import "shared.proto";
// Very simplified version of our account service.
service AccountService {
rpc SendEmailVerification(VerificationRequest) returns(shared.Empty);
@enyo
enyo / simple_server.dart
Last active Sep 30, 2021
Writing server side Dart code
View simple_server.dart
import 'dart:io';
main() async {
final server = await HttpServer.bind(InternetAddress.anyIPv6, 80);
server.listen((HttpRequest request) {
request.response.write('Hello, world!');
request.response.close();
});
}
View jquery-dropzone.js
// Get the template HTML and remove it from the doument.
var previewNode = document.querySelector("#template");
previewNode.id = "";
var previewTemplate = previewNode.parentNode.innerHTML;
previewNode.parentNode.removeChild(previewNode);
var myDropzone = new Dropzone(document.body, { // Make the whole body a dropzone
url: "/target-url", // Set the url
thumbnailWidth: 80,
thumbnailHeight: 80,
@enyo
enyo / gist:4726916
Created Feb 6, 2013
Tweek dropzone to use another container for file previews
View gist:4726916
Dropzone.myDropzone.options = {
addedfile: function(file) {
file.previewTemplate = $(this.options.previewTemplate);
this.element.find(".previews").append(file.previewTemplate);
file.previewTemplate.find(".filename span").text(file.name);
file.previewTemplate.find(".details").append($("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
}
};