diff --git a/autoload.php b/autoload.php index 7c2c1c78..e79cdbe1 100644 --- a/autoload.php +++ b/autoload.php @@ -24,7 +24,7 @@ class Autoloader public static function reload($reload = false) { - $key = 'lbry-classes-4'; + $key = 'lbry-classes-5'; if (ini_get('apc.enabled') && !$reload) { $classes = apc_fetch($key, $success); diff --git a/controller/Controller.class.php b/controller/Controller.class.php index a531d4ce..59508f3c 100644 --- a/controller/Controller.class.php +++ b/controller/Controller.class.php @@ -49,6 +49,10 @@ class Controller return ContentActions::executeHome(); case '/fund': return CreditActions::executeFund(); + case '/fund-after': + return ['fund/fund-after']; + case '/goals': + return ['fund/goals']; case '/get': case '/windows': case '/ios': diff --git a/controller/action/ContentActions.class.php b/controller/action/ContentActions.class.php index fc75a5af..3cf5dae7 100644 --- a/controller/action/ContentActions.class.php +++ b/controller/action/ContentActions.class.php @@ -15,7 +15,7 @@ class ContentActions extends Actions public static function executeHome() { - return ['page/home', [ + return ['content/home', [ 'totalUSD' => CreditApi::getTotalDollarSales(), 'totalPeople' => CreditApi::getTotalPeople() ]]; diff --git a/data/i18n/en.yaml b/data/i18n/en.yaml new file mode 100644 index 00000000..eb7214ef --- /dev/null +++ b/data/i18n/en.yaml @@ -0,0 +1,8 @@ +global: + tagline: Play, Share, Earn. + sentence: Watch, read and play in a decentralized digital library controlled by the community. +email: + disclaimer: You will receive 1-2 messages a month, only from LBRY, Inc. and only about LBRY. You can easily unsubscribe at any time. +download: + main: + title: LBRY for %os% \ No newline at end of file diff --git a/data/i18n/pt.yaml b/data/i18n/pt.yaml new file mode 100644 index 00000000..2be7c4ea --- /dev/null +++ b/data/i18n/pt.yaml @@ -0,0 +1,5 @@ +tagline: Play, Compartilhar, ganhem. +sentence: Assistir, ler e jogar em uma biblioteca digital descentralizada controlado pela comunidade. +download: + main: + title: LBRY para %os% \ No newline at end of file diff --git a/lib/i18n.class.php b/lib/i18n.class.php index d52eaa9b..4ce0f5c1 100644 --- a/lib/i18n.class.php +++ b/lib/i18n.class.php @@ -4,8 +4,8 @@ * i18n dummy we'll be happy to have later */ function __($msg, $args = []) -{ - return strtr($msg, $args); +{ + return strtr(i18n::translate($msg), $args); } /** @@ -15,9 +15,43 @@ function __($msg, $args = []) */ class i18n { - public static function register() /*needed to trigger class include, presumably setup would happen here*/ + protected static + $language = null, + $translations = [], + $country = null; + + public static function register($culture = null) /*needed to trigger class include, presumably setup would happen here*/ { - setlocale(LC_MONETARY, 'en_US.UTF-8'); + if ($culture === null) + { + $urlTokens = $_SERVER['HTTP_HOST'] ? explode('.', $_SERVER['HTTP_HOST']) : []; + $code = $urlTokens ? reset($urlTokens) : 'en'; + switch($code) + { + case 'pt': + $culture = 'pt_PT'; break; + case 'en': + case 'www': + default: + $culture = 'en_US'; + } + } + + list($language, $country) = explode('_', $culture); + static::$language = $language; + static::$country = $country; + + setlocale(LC_MONETARY, $culture . '.UTF-8'); + } + + public static function getLanguage() + { + return static::$language; + } + + public static function getCountry() + { + return static::$country; } public static function formatCurrency($amount, $currency = 'USD') @@ -29,4 +63,31 @@ class i18n { return '' . number_format($amount, 1) . ' LBC'; } + + public static function translate($token, $language = null) + { + $language = $language === null ? static::$language : $language; + if (!isset(static::$translations[$language])) + { + $path = ROOT_DIR . '/data/i18n/' . $language . '.yaml'; + static::$translations[$language] = file_exists($path) ? Spyc::YAMLLoadString(file_get_contents($path)) : []; + } + $scope = static::$translations[$language]; + foreach(explode('.', $token) as $level) + { + if (isset($scope[$level])) + { + $scope = $scope[$level]; + } + else + { + $scope = []; + } + } + if (!$scope && $language != 'en') + { + return static::translate($token, 'en'); + } + return $scope ?: $token; + } } diff --git a/view/View.class.php b/view/View.class.php index 7c1aa703..c94e296f 100644 --- a/view/View.class.php +++ b/view/View.class.php @@ -50,7 +50,8 @@ class View throw $e; } - return ob_get_clean(); + + return static::interpolateTokens(ob_get_clean()); } public static function exists($template) @@ -108,4 +109,11 @@ class View $css = $scssCompiler->compile(file_get_contents(ROOT_DIR.'/web/scss/all.scss')); file_put_contents(ROOT_DIR.'/web/css/all.css', $css); } + + protected static function interpolateTokens($html) + { + return preg_replace_callback('/{{[\w\.]+}}/is', function($m) { + return i18n::translate(trim($m[0], '}{')); + }, $html); + } } \ No newline at end of file diff --git a/view/template/page/home.php b/view/template/content/home.php similarity index 93% rename from view/template/page/home.php rename to view/template/content/home.php index 63c53307..5392ffc0 100644 --- a/view/template/page/home.php +++ b/view/template/content/home.php @@ -7,10 +7,8 @@
-

Play, Share, Earn.

-

- Watch, read and play in a decentralized digital library controlled by the community. -

+

{{tagline}}

+

{{sentence}}

-

LBRY for

+

$osTitle]) ?>

diff --git a/view/template/page/fund-after.php b/view/template/fund/fund-after.php similarity index 100% rename from view/template/page/fund-after.php rename to view/template/fund/fund-after.php diff --git a/view/template/page/goals.php b/view/template/fund/goals.php similarity index 100% rename from view/template/page/goals.php rename to view/template/fund/goals.php diff --git a/view/template/mail/joinList.php b/view/template/mail/joinList.php index e831fca8..895f38a5 100644 --- a/view/template/mail/joinList.php +++ b/view/template/mail/joinList.php @@ -25,8 +25,7 @@
- - + {{email.disclaimer}}
diff --git a/view/template/page/docs.php b/view/template/page/docs.php deleted file mode 100644 index e2b632d0..00000000 --- a/view/template/page/docs.php +++ /dev/null @@ -1,65 +0,0 @@ - - false]) ?> -
-
-

Docs

-

Layer 1: Protocol

-

While the protocol is one comprehensive set of rules, it is easier to understand as two parts.

-

Part A: The LBRY Blockchain

-

A blockchain, or distributed ledger is the key innovation behind the Bitcoin network. Blockchains solved the very complicated technological problem of having a bunch of distributed, disparate entities all agree on a rivalrous state of affairs (like how much money they owe each other).

- -

Like Bitcoin, the LBRY blockchain maintain balances -- in this case, balances of LBC, LBRY’s unit of credit. More importantly, the LBRY blockchain also provides a decentralized lookup and metadata storage system. The LBRY blockchain supports a specific set of commands that allows anyone to bid (in LBC) to control a LBRY name, which is a lot like a domain name. Whoever controls a name gets to describe what it contains, what it costs to access, who to pay, and where to find it. These names are sold in a continuous running auction. We will talk more about this system a little later on.

- -

If you’re a programmer, you might recognize the LBRY blockchain as a key-value store. Each key, or name, corresponds to a value, or a metadata entry. Whichever party or parties bid the most LBC gets to control the metadata returned by a key lookup.

- -

Here is a sample key-value entry in the LBRY blockchain. Here, wonderfullife is the key, and the rest of the description is the value.

-
-
-    wonderfullife : {
-      title: "It’s a Wonderful Life",
-      description: "An angel helps a compassionate but despairingly frustrated businessman by showing what life would have been like if he never existed.",
-      thumbnail: "http://i.imgur.com/MW45x88.jpg",
-      license: "public domain",
-      price: 0, //free!
-      publisher: "A Fan Of George Bailey", //simplification
-      sources: { //extensible, variable list
-        lbry_hash : <unique id>,
-        url : <url>
-      }
-    }
-
-

A slightly simplified sample entry of metadata in the LBRY blockchain. Whichever party or parties bid the most in an ongoing auction control what a name returns.

- -

Other than the usage of the LBRY blockchain to store names and metadata, there are only minor differences between the blockchains of LBRY and Bitcoin, and the changes are generally consensus improvements. We’ve buffed the hashing algorithm, smoothed the block reward function, increased the block size, increased the total number of credits, and prepared for offchain settlement.

- -

The LBRY blockchain simply maintains LBC balances and a content namespace/catalogue. The next part, LBRYnet, specifies what to do with this data. To compare to the existing web, the blockchain is like the domain system (it maintains a listing of what is available), while the next piece makes it possible to actually fetch and pay for content.

-
If you’re a Bitcoiner wondering why we don’t use the Bitcoin blockchain, you can read a detailed answer to that question here.
- -

Part B: The Data Network (LBRYNet)

-

LBRYNet is the layer that makes the LBRY blockchain useful beyond a simple payment system. It says what to do with the information available in the LBRY blockchain, how to issue payments, how to look up a content identifier, and so on.

- -

To use the LBRY network, a user’s computer needs the capacity to speak LBRY. That layer is LBRYNet. Just as your computer has a library that enables it to understand HTTP, DNS, and other languages and protocols, LBRYNet is the piece of software that allows your computer to understand how to interact with the LBRY network.

- -

To understand what role LBRYNet plays, let’s drill a little more into a sample user interaction. Once a user has affirmed access and purchase, such as in step 5 of our Sample Use above, the following happens:

- -
    -
  1. LBRYNet issues a lookup for the name associated with the content. If the client does not have a local copy of the blockchain, this lookup is broadcast to miners or to a service provider. This lookup acquires the metadata associated with the name.
  2. -
  3. LBRYNet issues any required payments, as instructed by metadata entries. -
      -
    1. If the content is set to free, nothing happens here.
    2. -
    3. If the content is set to have a price in LBC, the client must issue a payment in LBC to the specified address. If the content is published encrypted, LBRYNet will not allow access until this payment has been issued.
    4. -
    5. If the content is set to have another payment method, the seller must run or use a service that provides a private server enforcing payment and provisioning accessing keys.
    6. -
    -
  4. -
  5. Simultaneous to #2, LBRYNet uses the metadata to download the content itself. -
      -
    1. The metadata allows chunks to be discovered and assembled in a BitTorrent-like fashion. However, unlike BitTorrent, chunks do not individually identify themselves as part of a greater whole. Chunks are just arbitrary pieces of data.
    2. -
    3. If LBRYNet cannot find nodes offering chunks for free, it will offer payments for chunks to other hosts with those chunks.
    4. -
    5. This payment is not done via proof-of-bandwidth, or third-party escrow. Instead, LBRYNet uses reputation, trust, and small initial payments to ensure reliable hosts.
    6. -
    7. If content is not published directly to LBRY, the metadata can instruct other access methods, such as a Netflix URL. This allows us to catalogue content not yet available on LBRY as well as offer legacy and extensibility purposes.
    8. -
    -
  6. -
-
-
- \ No newline at end of file diff --git a/view/template/page/learn-old.php b/view/template/page/learn-old.php deleted file mode 100644 index 6f05a6aa..00000000 --- a/view/template/page/learn-old.php +++ /dev/null @@ -1,70 +0,0 @@ - - - false]) ?> -
-
-
-
-

-
-
- - Screenshot of a LBRY browser - -
-

Puts on jargon hat.

-

- LBRY is a decentralized, censorship-resistant, open-source, peer-to-peer information marketplace and discovery protocol. -

-

Removes jargon hat.

-

- LBRY is a new way for people to publish and share content with each other. -

-

- Our goal is to provide a single box that allows anyone anywhere to find and purchase digital content from anyone else. -

-
- -
-
-
-
-
-
-

-
-

-

-

-

-

-
-
- -
-
- -
-
- Credit SMBC. -
-
-
-
-
-
-
-

-
-

-

-
-
- -
- <?php echo __('LBRY Founders') ?> -
-
-
-
- \ No newline at end of file diff --git a/view/template/page/learn.php b/view/template/page/learn.php index c9b867e7..3ee5ebd2 100644 --- a/view/template/page/learn.php +++ b/view/template/page/learn.php @@ -1,7 +1,6 @@ false]) ?> -
diff --git a/view/template/page/publish.php b/view/template/page/publish.php deleted file mode 100644 index 1a17a464..00000000 --- a/view/template/page/publish.php +++ /dev/null @@ -1,47 +0,0 @@ - - - false]) ?> -
-
-

-

Own or create content? Release your work on LBRY and be ahead of the curve.

-
-
-
-

Publish instantly, everywhere, for free.

-
-
-
- -
-

Global, Robust Distribution

-

- LBRY uses ground-breaking technology to make your content instantly available worldwide, - with no ability for us or anyone else to remove or censor your content. -

-
-
-
- -
-

Creators in Control

-

Update your content at any time. Change the price. Change the title. Publish, unpublish. You and only you can do this in LBRY.

-
-
-
- -
-

More, Better Profit

-

Any price you charge for content settles near-instantly into an account only you control. You receive 100% of the price.

-
-
-
-
-
-

-

LBRY is currently in alpha testing, preparing for a public release.

- -
-
- diff --git a/view/template/page/test.php b/view/template/page/test.php new file mode 100644 index 00000000..047c9ab4 --- /dev/null +++ b/view/template/page/test.php @@ -0,0 +1,10 @@ + + + false]) ?> +
+
+
+
+
+ + \ No newline at end of file diff --git a/view/template/page/what-old.php b/view/template/page/what-old.php deleted file mode 100644 index 53467ec4..00000000 --- a/view/template/page/what-old.php +++ /dev/null @@ -1,99 +0,0 @@ - - - false]) ?> -
-
-
-

A revolution in accessing and publishing information.

-
-
-
- -
-

- Hosts earn credits for providing bandwidth and disk space. -

-
-
-
- -
-

- Miners earn credits for securing balances and metadata. -

-
-
-
- -
-

- Patrons spend credits to access content without gatekeepers. -

-
-
-
-
-
-

What is LBRY?

-
-

LBRY allows anyone to publish content to a location like this:

-

lbry://wonderfullife

-

Others can access this resource, either for free or for credits. Let's look at an example:

-
    -
  1. Ernest wants to release his comedy-horror film, "Ernie Goes To Guantanamo Bay".
  2. -
  3. The content is encrypted and sliced into many pieces. These pieces are stored by hosts.
  4. -
  5. Ernest reserves lbry://erniebythebay, a shortname pointing to his content.
  6. -
  7. When Ernest reserves the location, he also submits metadata, such as a description and thumbnail. This information is stored by miners in the LBRY blockchain.
  8. -
  9. Hilary, a patron, browses the LBRY network and wants to watch the movie. - Her LBRY client collects the pieces from the hosts and reassembles them.
  10. -
  11. Hilary pays Ernest for the decryption key, allowing her to watch the film.
  12. -
-
-
-
-
-

If BitTorrent + BitCoin Had a Baby

-
-
- -

Decentralized Metadata

-

Information about content is embedded in a blockchain, eliminating centralized failure points. Metadata and data are completely decoupled so that hosts never see metadata and miners never see data.

-
-
- -

Marketized Data-Transfer

-

Patrons request content for free or offer credits for faster speeds or access. Hosts share or sell surplus bandwidth and disk space.

-
-
- -

Memorable URIs

-

- Publishers can choose friendly resource indicators like lbry://wonderfullife instead of ugly BitTorrent magnet URIs. - URIs are reserved rather than owned, creating strong incentive for rights holders to use LBRY. -

-
-
-
-
- -

Payments to Publishers

-

Publishers may embed an address to receive payment for data. Publishers can also create assurance contracts? for new content.

-
-
- -

Improved Privacy

-

LBRY uses novel techniques to protect publishers, providers, and consumers. - Hosts only have small portions of an encrypted file with no information of the contents. -

-
-
- -

Designed for Developers

-

LBRY is designed to allow others to create applications powered by it’s distributed, robust data store.

-
-
-
-
- -
- diff --git a/view/template/page/why.php b/view/template/page/why.php deleted file mode 100644 index 6a7725b7..00000000 --- a/view/template/page/why.php +++ /dev/null @@ -1,107 +0,0 @@ - - - - false]) ?> -
-
-
-
-
-

If you made the music, and you made the art, and you put it into the world, I should be able to use it. I'ma pay you, I'ma give you a percentage, but... you was inspired by the world; allow the world to be inspired by your [work] and to use your [work].

-
- J. Cole, Note to Self -
-
-
-

Why?

-
-

The World We Live In

-

Annual internet video traffic is approximately 500 exabytes (500,000,000,000 GB)1. - Every second, over 10,000 hours of video are streamed. - The technical term for the quantity of videos people watch every year is a million jillion. You know this.

- -

What you may not know: video distribution is fundamentally flawed.

-

- The fatal flaw of existing systems is their centralized, top-down design. The consequences: -

-
    -
  1. Increased costs to consumers. Providers bear significant infrastructure costs, regulatory and compliance costs, - and must create complex systems to govern a simple process (copying a number).

  2. -
  3. Terrible consumer experience. - Centralization leads to fragmentation, as providers compete to lock numbers in digit dungeons.

    -
  4. -
  5. -

    Poor producer experience. - The primary want of a producer is to be paid for making things. Instead, producers frequently lose control of their content and - lose profits to the inefficiency of current systems.

    -
  6. -
-

Similar issues of economics and experience exist for consumers and producers of information of all kinds (e.g. news, facts), not just videos.

- -

LBRY solves these problems and throws in some other sweet innovations just for funsies.

-
-
-
-
-
-

Information is power.

-

But like all power, there are those who want to keep it for themselves. -

- Aaron Swartz -
-
-
-
-

An Alternative

-

LBRY avoids the mistakes of centralization and middlemen. It says:

-
    -
  1. -

    - Information isn't a thing - Things are physical and exist in the world. When I have a thing, you can't. Economists call this rivalry?. -

    -

    - Information is non-rival. Information is just a number. There is nothing easier to replicate than information. - LBRY embraces (and adores) this reality. -

    -

    - LBRY breaks information into thousands of identifiable tiny pieces and spreads them throughout the internet, reducing costs - for both providers and consumers. -

    -
    - XKCD #1228 Prometheus - -
    -
  2. -
  3. -

    - Connecting creators and consumers directly is best. - Do we need middlemen spending billions to extract their rent and police others? - A better system allows consumers to easily and directly pay content creators. - We want to eliminate extortionists charging tolls. -

    -

    - On LBRY, publishers sell directly to patrons. Publishers can charge a set fee per decryption key for content or create an assurance contract for unpublished content. -

    -
  4. -
  5. -

    It's Up to Us. A smart guy once said that power corrupts and absolute power corrupts absolutely.

    -

    - LBRY leaves no one in charge (including us). It puts power in the hands of individuals and users rather than corporations and executives. -

    -

    We think that world will be more creative, more charitable, and more fair. We hope you'll join us in creating it.

    -
  6. - -
-

What LBRY Isn't

-

LBRY's fully decentralized nature makes restricting content impossible. Since LBRY also aims to unseat gigantic, established media players, - we fear it may attract undeserved legal attention. So we'd like to be clear from day one:

-

- LBRY is not about facilitating piracy. - LBRY is about creating a network where creators and patrons can directly interact without relying on anyone in the middle. We've made choices - about publisher identities and how addresses are reserved that are specifically designed to combat undue profiteering.

-
- -
- -1.

*/ ?>