text:
mobile-gutenberg
================

It's my intent to create a guide, and glue-code where necessary, for a news site which is collaboratively written and edited. This is the repository for such.

This is just a mirage, a collation. disregard. PR's welcome.

### Intentional Design Constraints
Site is to be optimized for phone access via 3g (not 3.5g). Writing, editing, and all the rest, should all be possible on a smartphone. Any page load optimizations which can be made at generation-time, should be made. Every KiB counts on an unstable/slow connection. TLS is mandatory (you don't hate your users, writers, contributors, or editors, do you?). Ads are not allowed.

### Prerequisites
- Github account
- [Prose](http://prose.io/) / [hallo](http://hallojs.org/) + ???
- [jekyll](https://github.com/jekyll/jekyll)
- [jekyll-hook](https://github.com/developmentseed/jekyll-hook)
- [jekyll-sort](https://github.com/kylepaulsen/Jekyll-Sort)
- [jekyll-ga](https://github.com/developmentseed/jekyll-ga) or similar
- [jekyll-filename](https://github.com/developmentseed/jekyll-filename)
- [jQuery](http://jquery.com/) / [jQlite](https://code.google.com/p/jqlite/)
- [Isotope](http://isotope.metafizzy.co/)
- ?[Poole](https://github.com/poole/poole) + [Lanyon](http://lanyon.getpoole.com/)
- some mobile-first (mobile-only?) css
- perhaps a cronjob to regenerate the homepage instead of isotope+company. with css variables perhaps it can be randomized in css and not via js.

Things which will make this better, offsite:
- ramnode $5/mo vps
- cloudflare OR cloudfront+s3 + s3cmd
- mod_pagespeed
- spdy/tls

### Still to research
what jekyll plugins does github pages support? (IE: can there be a stripped down version of this project which can be run entirely through github, with an acceptable level of compromise to the design constraints?)

is jQuery even feasible on mobile, due to how fucking gigantic it is? can a smaller version be built that gets rid of animations and things, while being significantly smaller? -> jQlite seems to answer this. How powerful it is, is another question. I'd rather avoid js anywhere other than the editing interface, if I can (and for that, prose will do).

analytics for journalists -> interviews for what qualifies as a good article

### Provisional front-end stack
- [LeafletJS](http://leafletjs.com/) or [OpenLayers](http://openlayers.org/)
- [Isotope](http://isotope.metafizzy.co/) or [Masonry.js](http://masonry.desandro.com/) or [Salvattore](http://salvattore.com/) or [FreeTile](http://yconst.com/web/freetile/)
- [ImagesLoaded](http://imagesloaded.desandro.com/)
- [Lato](https://www.google.com/fonts/specimen/Lato) or [Raleway](http://www.google.com/fonts/specimen/Raleway) 900 for titles, [Merriweather](http://www.google.com/fonts/specimen/Merriweather) for body. [Source Code Pro](https://www.google.com/fonts/specimen/Source+Code+Pro) for blockquotes. With money, use [skolar](https://www.rosettatype.com/Skolar)/[huronia](https://www.rosettatype.com/Huronia) for body, [Satyr](https://monokrom.no/fonts/satyr) for blockquotes, idk for titles maybe [Lumin Sans Thin](https://www.typotheque.com/site/fonts.php?id=79&tn=sample_text&style=1199&size=waterfall&regen=1) or something.
- These all look absolutely gorgeous, but serif/sans-serif/monospace are the least KiB.

### Scratchpad
militant transparency without Real Names™

transparency without authority. authentication without authorization

collaborative news, at writing and editing level, with nyms not names

http://openrouteservice.org/

http://www.hotosm.org/

http://mapnik.org/

principle of least effort

principle of least authority

privacy: the capacity to continue personal information asymmetries

static pages as technological force multiplier due to global caching

fuck unequal power dynamics

truth above all else

militant transparency

flat ontologies and power arrangements prevent idolization and minimize exploitation

"neutralization of unequal power dynamics and distributions written into the sourcecode"

fiat as triage for poverty, time as arbiter of experience, edit for alacrity, sympathetic imagination as organizational structure, link all the things,
editorial policy: people are named as they introduce themselves, and pronouned as they do.

before peace, there must be justice. before equality, there must be equity.

ads = brand dilution.

must be able to run site on income of a coffee farmer

hmmhmm. public infrastructure is public whether the law reflects that or not. Usage patterns are defacto.

risk is energy, it cannot be created or destroyed only changed.
conservation of mass, conservation of energy, laws of thermodynamics, all are the same thing.
you can transfer risk onto another party via contract, practice, or system, but it can never be created or destroyed.

what principles guide this software? how is the world constructed?

least-bad ads: "Wealth or at least a humble self-sustaining income will be yours for the mere cost of a few inches of your website. This is a very, very powerful message, if you don't notice the Pimp behind it." -[sauce](http://www.textfiles.com/thoughts/advertising.html)

versahq, project wonderful.

embedly

challenge: being leaked to

ideé: because this is designed to be loaded via 3g, pop a small js in that quicktests the navigationtiming1/2 PLT. If it's under a ceiling, ajax in extra functionality.

### spam (copy-pasted from notepad)
list: chartbeat (for TTR and similar), gravity (pinch hit), storify

licenses: Author chooses at creation time, select from CC licenses.

jekyll for output, something which can emit markdown for the writing interface. apache for writing interface, nginx/lighttpd for static html.

so, use prose.io with a private github repo (25/mo for org), with jekyll-hook and a 5/mo digital ocean box for hosting. google apps for email.

why can't I do this without github? can prose be deployed with alternative git backing? can I just use, say, cryto git hosting? could even take jekyll-hook and push to s3 with cloudfront in front.

https://github.com/developmentseed/jekyll-hook,

http://hallojs.org/demo/markdown/ ( https://github.com/bergie/hallo )

http://joshualande.com/jekyll-github-pages-poole/

https://github.com/kylepaulsen/Jekyll-Sort

https://github.com/developmentseed/jekyll-ga

http://jekyllrb.com/docs/plugins/

https://github.com/barryclark/jekyll-now

http://www.smashingmagazine.com/2014/08/01/build-blog-jekyll-github-pages/

https://help.github.com/articles/using-jekyll-plugins-with-github-pages

https://github.com/chartbeat-labs

https://github.com/jarofghosts/peabody

http://aloha-editor.org/

http://wymeditor.github.io/wymeditor/

http://developmentseed.org/blog/all/

MOD PAGESPEED! AND CLOUDFLARE

TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256


text:
package io.particle.android.sdk.accountsetup;

import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.Switch;

import com.segment.analytics.Properties;
import com.squareup.phrase.Phrase;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import io.particle.android.sdk.cloud.ParticleCloud;
import io.particle.android.sdk.cloud.exceptions.ParticleCloudException;
import io.particle.android.sdk.cloud.ParticleCloudSDK;
import io.particle.android.sdk.cloud.SDKGlobals;
import io.particle.android.sdk.cloud.models.AccountInfo;
import io.particle.android.sdk.cloud.models.SignUpInfo;
import io.particle.android.sdk.devicesetup.R;
import io.particle.android.sdk.devicesetup.R2;
import io.particle.android.sdk.ui.BaseActivity;
import io.particle.android.sdk.ui.NextActivitySelector;
import io.particle.android.sdk.utils.Async;
import io.particle.android.sdk.utils.SEGAnalytics;
import io.particle.android.sdk.utils.TLog;
import io.particle.android.sdk.utils.ui.ParticleUi;
import io.particle.android.sdk.utils.ui.Toaster;
import io.particle.android.sdk.utils.ui.Ui;

import static io.particle.android.sdk.utils.Py.truthy;

public class CreateAccountActivity extends BaseActivity {

    private static final TLog log = TLog.get(CreateAccountActivity.class);

    /**
     * Keep track of the login task to ensure we can cancel it if requested, ensure against
     * duplicate requests, etc.
     */
    private Async.AsyncApiWorker<ParticleCloud, Void> createAccountTask = null;

    // UI references.
    @BindView(R2.id.first) protected EditText firstNameView;
    @BindView(R2.id.last) protected EditText lastNameView;
    @BindView(R2.id.company) protected EditText companyNameView;
    @BindView(R2.id.email) protected EditText emailView;
    @BindView(R2.id.password) protected EditText passwordView;
    @BindView(R2.id.verify_password) protected EditText verifyPasswordView;
    @BindView(R2.id.companyAccount) protected Switch companyChoiceView;

    @OnClick(R2.id.already_have_an_account_text)
    protected void onHasAccountClick(View view) {
        startActivity(new Intent(view.getContext(), LoginActivity.class));
        finish();
    }

    @OnCheckedChanged(R2.id.companyAccount)
    protected void onCompanyCheckedChange(boolean isChecked) {
        if (isChecked) {
            int backgroundDefault = ContextCompat.getColor(CreateAccountActivity.this,
                    R.color.register_field_background_color_enabled);
            verifyPasswordView.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            companyNameView.setBackgroundColor(backgroundDefault);
            companyChoiceView.setText(R.string.prompt_company_account_enabled);
        } else {
            verifyPasswordView.setImeOptions(EditorInfo.IME_ACTION_DONE);
            companyNameView.setBackgroundColor(ContextCompat.getColor(CreateAccountActivity.this,
                    R.color.register_field_background_color_disabled));
            companyChoiceView.setText(R.string.prompt_company_account_disabled);
        }
        companyNameView.setEnabled(isChecked);
    }

    private boolean useOrganizationSignup;
    private boolean useProductionSignup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_account);
        ButterKnife.bind(this);
        SEGAnalytics.screen("Auth: Sign Up screen");
        ParticleUi.enableBrandLogoInverseVisibilityAgainstSoftKeyboard(this);

        Ui.setText(this, R.id.create_account_header_text,
                Phrase.from(this, R.string.create_account_header_text)
                        .put("brand_name", getString(R.string.brand_name))
                        .format()
        );

        useOrganizationSignup = getResources().getBoolean(R.bool.organization);
        useProductionSignup = getResources().getBoolean(R.bool.productMode);

        Ui.setTextFromHtml(this, R.id.already_have_an_account_text, R.string.msg_user_already_has_account);

        if (getResources().getBoolean(R.bool.show_sign_up_page_fine_print)) {
            String tosUri = getString(R.string.terms_of_service_uri);
            String privacyPolicyUri = getString(R.string.privacy_policy_uri);

            String finePrintText = Phrase.from(this, R.string.msg_create_account_disclaimer)
                    .put("tos_link", tosUri)
                    .put("privacy_policy_link", privacyPolicyUri)
                    .format().toString();
            Ui.setTextFromHtml(this, R.id.fine_print, finePrintText)
                    .setMovementMethod(LinkMovementMethod.getInstance());
        } else {
            Ui.findView(this, R.id.fine_print).setVisibility(View.GONE);
        }
    }

    /**
     * Attempts to sign in or register the account specified by the login form.
     * If there are form errors (invalid email, missing fields, etc.), the
     * errors are presented and no actual login attempt is made.
     */
    @OnClick(R2.id.action_create_account)
    public void attemptCreateAccount() {
        if (createAccountTask != null) {
            log.wtf("Sign up being attempted again even though the sign up button isn't enabled?!");
            return;
        }

        // Reset errors.
        emailView.setError(null);
        passwordView.setError(null);
        firstNameView.setError(null);
        lastNameView.setError(null);
        companyNameView.setError(null);

        // Store values at the time of the login attempt.
        final String email = emailView.getText().toString();
        final String password = passwordView.getText().toString();

        boolean cancel = false;
        View focusView = null;

        // Check for a valid email address.
        if (!truthy(email)) {
            emailView.setError(getString(R.string.error_field_required));
            focusView = emailView;
            cancel = true;
        } else if (!isEmailValid(email)) {
            emailView.setError(getString(R.string.error_invalid_email));
            focusView = emailView;
            cancel = true;
        }

        // Check for a valid password.
        if (TextUtils.isEmpty(password)) {
            passwordView.setError(getString(R.string.error_field_required));
            focusView = passwordView;
            cancel = true;
        } else if (!isPasswordValid(password)) {
            passwordView.setError(getString(R.string.error_invalid_password));
            focusView = passwordView;
            cancel = true;
        } else if (!password.equals(verifyPasswordView.getText().toString())) {
            passwordView.setError(getString(R.string.create_account_passswords_do_not_match));
            verifyPasswordView.setError(getString(R.string.create_account_passswords_do_not_match));
            focusView = passwordView;
            cancel = true;
        }
        boolean empty;
        // Check for a company account checked state
        if (companyChoiceView.isChecked()) {
            // Check for a valid company name
            empty = isFieldEmpty(companyNameView);
            cancel = empty || cancel;
            focusView = empty ? companyNameView : focusView;
        }
        // Check for a valid Last name
        empty = isFieldEmpty(lastNameView);
        cancel = empty || cancel;
        focusView = empty ? lastNameView : focusView;
        // Check for a valid First name
        empty = isFieldEmpty(firstNameView);
        cancel = empty || cancel;
        focusView = empty ? firstNameView : focusView;

        if (cancel) {
            // There was an error; don't attempt login and focus the first
            // form field with an error.
            focusView.requestFocus();
        } else {
            attemptSignUp();
        }
    }

    private void attemptSignUp() {
        AccountInfo accountInfo = new AccountInfo();
        accountInfo.setFirstName(firstNameView.getText().toString());
        accountInfo.setLastName(lastNameView.getText().toString());
        accountInfo.setCompanyName(companyNameView.getText().toString());
        accountInfo.setBusinessAccount(companyChoiceView.isChecked());
        // Store values at the time of the signup attempt.
        final String email = emailView.getText().toString();
        final String password = passwordView.getText().toString();
        SignUpInfo signUpInfo = new SignUpInfo(email, password, accountInfo);
        // Show a progress spinner, and kick off a background task to
        // perform the user login attempt.
        ParticleUi.showParticleButtonProgress(this, R.id.action_create_account, true);
        final ParticleCloud cloud = ParticleCloudSDK.getCloud();
        createAccountTask = Async.executeAsync(cloud, new Async.ApiWork<ParticleCloud, Void>() {
            @Override
            public Void callApi(@NonNull ParticleCloud particleCloud) throws ParticleCloudException {
                if (useOrganizationSignup && !useProductionSignup) {
                    throw new ParticleCloudException(new Exception("Organization is deprecated, use productMode instead."));
                } else if (useProductionSignup) {
                    int productId = getResources().getInteger(R.integer.product_id);
                    if (productId == 0) {
                        throw new ParticleCloudException(new Exception("Product id must be set when productMode is in use."));
                    }
                    particleCloud.signUpAndLogInWithCustomer(signUpInfo, productId);
                } else {
                    particleCloud.signUpWithUser(signUpInfo);
                }
                return null;
            }

            @Override
            public void onTaskFinished() {
                createAccountTask = null;
            }

            @Override
            public void onSuccess(@NonNull Void result) {
                singUpTaskSuccess(email, password, accountInfo, cloud);
            }

            @Override
            public void onFailure(@NonNull ParticleCloudException error) {
                signUpTaskFailure(error);
            }
        });
    }

    private void singUpTaskSuccess(String email, String password, AccountInfo accountInfo, ParticleCloud cloud) {
        SEGAnalytics.track("android account creation", new Properties()
                .putValue("email", email)
                .putValue("firstname", accountInfo.getFirstName())
                .putValue("lastname", accountInfo.getLastName())
                .putValue("isbusiness", accountInfo.isBusinessAccount())
                .putValue("company", accountInfo.getCompanyName()));
        log.d("onAccountCreated()!");
        if (isFinishing()) {
            return;
        }
        if (useOrganizationSignup || useProductionSignup) {
            // with org setup, we're already logged in upon successful account creation
            onLoginSuccess(cloud);
            SEGAnalytics.track("Auth: Signed Up New Customer");
        } else {
            SEGAnalytics.track("Auth: Signed Up New User");
            attemptLogin(email, password);
        }
    }

    private void signUpTaskFailure(@NonNull ParticleCloudException error) {
        log.d("onFailed()");
        ParticleUi.showParticleButtonProgress(CreateAccountActivity.this,
                R.id.action_create_account, false);

        String msg = getString(R.string.create_account_unknown_error);
        if (error.getKind() == ParticleCloudException.Kind.NETWORK) {
            msg = getString(R.string.create_account_error_communicating_with_server);

        } else if (error.getResponseData() != null) {

            if (error.getResponseData().getHttpStatusCode() == 401
                    && (getResources().getBoolean(R.bool.organization) ||
                    getResources().getBoolean(R.bool.productMode))) {
                msg = getString(R.string.create_account_account_already_exists_for_email_address);
            } else {
                msg = error.getServerErrorMsg();
            }
        }
        //TODO remove once sign up error code is fixed
        if (error.getCause() != null && error.getCause().getMessage().contains(emailView.getText().toString())) {
            msg = getString(R.string.create_account_account_already_exists_for_email_address);
        }

        Toaster.l(CreateAccountActivity.this, msg, Gravity.CENTER_VERTICAL);
        emailView.requestFocus();
    }

    private boolean isFieldEmpty(EditText formField) {
        if (TextUtils.isEmpty(formField.getText().toString())) {
            formField.setError(getString(R.string.error_field_required));
            return true;
        }
        return false;
    }

    private boolean isEmailValid(String email) {
        return Patterns.EMAIL_ADDRESS.matcher(email).matches();
    }

    private boolean isPasswordValid(String password) {
        return (password.length() > 7);
    }

    private void onLoginSuccess(ParticleCloud cloud) {
        startActivity(NextActivitySelector.getNextActivityIntent(
                CreateAccountActivity.this,
                cloud,
                SDKGlobals.getSensitiveDataStorage(),
                null));
        finish();
    }

    private void attemptLogin(final String username, final String password) {
        final ParticleCloud cloud = ParticleCloudSDK.getCloud();
        Async.executeAsync(cloud, new Async.ApiWork<ParticleCloud, Void>() {
            @Override
            public Void callApi(@NonNull ParticleCloud particleCloud) throws ParticleCloudException {
                particleCloud.logIn(username, password);
                return null;
            }

            @Override
            public void onSuccess(@NonNull Void result) {
                log.d("Logged in...");
                if (isFinishing()) {
                    return;
                }
                onLoginSuccess(cloud);
            }

            @Override
            public void onFailure(@NonNull ParticleCloudException error) {
                log.w("onFailed(): " + error.getMessage());
                ParticleUi.showParticleButtonProgress(CreateAccountActivity.this,
                        R.id.action_create_account, false);
                passwordView.setError(error.getBestMessage());
                passwordView.requestFocus();
            }
        });

    }
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

  <title>locate.js</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />

          Jump To …
          +

                friends.js

                init.js

                notifications.js

                setMsg.js

                story.js

                trip.js

                liftapp.js

                locate.js

                marker.js

                directions.js

                initialise.js

                styles.js

                helper.js

                plugins.js

                coordinates.js

                friends.js

                invitees.js

                marker.js

                message.js

                notifications.js

                trip.js

                ui.js

                jquery.mobile-1.4.2.js

                jquery.mobile-1.4.2.min.js

                modernizr-2.6.2.min.js

                zepto.min.js

locate.js

                ¶

/*

	LiftApp (LA)

	Location helpers

 */

if (typeof LA.locations === "undefined" || !LA.locations)
	window.LA.locations = {};

/*
Location related methods
 */
LA.locations.locate = {

		/*
		Set the start point for the trip
		 */
		setStartPoint: function() {

		},

		/*
		Set the end point for the trip
		 */
		setEndPoint: function() {

		},

		/*
		Return the coordinates of the users current location if possible
		 */
		getOurLocation: function() {

			var
			fallbackLocation = new google.maps.LatLng( 53.27055, -9.05666 ),
			ourLocation,
			browserSupportFlag = false;

                ¶

/

                ¶

Try W3C Geolocation (Preferred)

			if (navigator.geolocation) {
				browserSupportFlag = true;

				navigator.geolocation.getCurrentPosition(function(position) {

					ourLocation = new google.maps.LatLng( position.coords.latitude, position.coords.longitude );

					LA.store.coordinates.ourLocation = ourLocation;

					LA.map.setCenter( ourLocation );

                ¶

LA.store.coordinates.startLocation = LA.locations.marker.placeMarker( ourLocation, LA.store.marker.icon.startPoint );

				}, function() {
					LA.map.setCenter( fallbackLocation );
				});
			}

                ¶

Browser doesn't support Geolocation

			else {
				LA.map.setCenter( fallbackLocation );
			}

		}
};


text:
package com.cc3002.auxiliar.design.pattern.composite.example02;

public interface IMenu extends IMenuComponent {

  long size();

  void addItem(IMenuComponent menuItem);

}


text:
package com.exsio.clock.ui;

import com.exsio.clock.AbstractDisplayAwareTest;
import com.google.common.base.Optional;
import org.testng.annotations.Test;

import java.awt.*;
import java.lang.reflect.Constructor;

import static org.testng.Assert.assertTrue;

public class UITest extends AbstractDisplayAwareTest {

    @Test
    public void test_getDesktop() {
        UI.setDesktop(null);
        Optional<Desktop> result = UI.getDesktop();
        assertTrue(result.isPresent());
    }

    @Test
    public void test_construct() throws Exception {
        Constructor constructor = UI.class.getDeclaredConstructor();
        constructor.setAccessible(true);
        constructor.newInstance();
    }
}


text:
from google.cloud import container_v1

async def sample_list_node_pools():
    # Create a client
    client = container_v1.ClusterManagerAsyncClient()

    # Initialize request argument(s)
    request = container_v1.ListNodePoolsRequest(
    )

    # Make the request
    response = await client.list_node_pools(request=request)

    # Handle the response
    print(response)

# [END container_v1_generated_ClusterManager_ListNodePools_async]


text:
'use strict';

var _querySelectorLive = require('../dom/querySelectorLive');

var _querySelectorLive2 = _interopRequireDefault(_querySelectorLive);

var _scrollTo = require('../dom/scrollTo');

var _scrollTo2 = _interopRequireDefault(_scrollTo);

var _easeInOutQuint = require('../easings/easeInOutQuint');

var _easeInOutQuint2 = _interopRequireDefault(_easeInOutQuint);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _querySelectorLive2.default)('[href^="scrollTo:#"]', function ($scrollElm) {
  $scrollElm.addEventListener('click', function (e) {
    e.preventDefault();
    var $target = document.querySelector('' + $scrollElm.getAttribute('href').substr(9));
    if (!$target) return;
    (0, _scrollTo2.default)($target, 600, _easeInOutQuint2.default);
  });
});