Skip to content

Commit

Permalink
Rename main project to alcova
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrewster committed Aug 18, 2020
1 parent a2f7409 commit 75cccda
Show file tree
Hide file tree
Showing 30 changed files with 82 additions and 154 deletions.
78 changes: 32 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
members = [
"./alcova",
"./alcova_macros",
"./example",
"./liveview",
"./alcova_examples",
]
12 changes: 10 additions & 2 deletions alcova/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
[package]
name = "alcova"
version = "0.1.0"
authors = ["Connor Brewster <[email protected]>"]
authors = ["Connor Brewster <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0"
actix = "0.9.0"
actix-web-actors = "2.0.0"
actix-web = "2.0.0"
alcova_macros = { path = "../alcova_macros" }
futures = "0.3.5"
jsonwebtoken = "7"
log = "0.4.8"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"

16 changes: 12 additions & 4 deletions alcova/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
mod ast;
mod parse;
#[macro_use]
extern crate log;

pub use ast::{BinaryOperator, CodeExpression, Expression, Pattern, Template, TypePath};
pub use parse::{parse_template, Parser};
mod live_socket;
mod live_template;
mod live_view;
mod registry;

pub use live_socket::{LiveSocket, LiveSocketContext};
pub use live_template::{Changes, LiveTemplate, RenderedTemplate, Slot};
pub use live_view::{LiveHandler, LiveMessage, LiveView, LiveViewContext};
pub use registry::LiveViewRegistry;
pub use alcova_macros::*;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions example/Cargo.toml → alcova_examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "example"
name = "alcova_examples"
version = "0.1.0"
authors = ["Connor Brewster <[email protected]>"]
authors = ["Connor Brewster <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
liveview = { path = "../liveview" }
alcova = { path = "../alcova" }
alcova_macros = { path = "../alcova_macros" }
actix = "0.9.0"
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions example/src/chat.rs → alcova_examples/src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::RootTemplate;
use actix::{Actor, Addr, AsyncContext, Context, Handler, Message, Recipient};
use actix_identity::Identity;
use actix_web::{http, web, HttpRequest, Responder};
use alcova_macros::LiveTemplate;
use liveview::{
use alcova::{
LiveHandler, LiveMessage, LiveSocketContext, LiveTemplate, LiveView, LiveViewContext,
};
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 1 addition & 2 deletions example/src/fruit.rs → alcova_examples/src/fruit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::RootTemplate;
use actix_web::{web, Responder};
use alcova_macros::LiveTemplate;
use liveview::{LiveSocketContext, LiveTemplate, LiveView, LiveViewContext};
use alcova::{LiveSocketContext, LiveTemplate, LiveView, LiveViewContext};

fn fruits() -> Vec<&'static str> {
include_str!("../fruits.txt").lines().collect()
Expand Down
3 changes: 1 addition & 2 deletions example/src/main.rs → alcova_examples/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use actix_files as fs;
use actix_identity::{CookieIdentityPolicy, IdentityService};
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer, Responder};
use actix_web_actors::ws;
use alcova_macros::LiveTemplate;
use alcova::{LiveSocket, LiveTemplate, LiveViewRegistry};
use chat::{ChatLive, Lobby};
use fruit::FruitLive;
use listenfd::ListenFd;
use liveview::{LiveSocket, LiveTemplate, LiveViewRegistry};
use timer::TimerLive;
use top::TopLive;

Expand Down
3 changes: 1 addition & 2 deletions example/src/timer.rs → alcova_examples/src/timer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::RootTemplate;
use actix::{AsyncContext, Message, SpawnHandle};
use actix_web::{web, Responder};
use alcova_macros::LiveTemplate;
use liveview::{
use alcova::{
LiveHandler, LiveMessage, LiveSocketContext, LiveTemplate, LiveView, LiveViewContext,
};
use std::time::{Duration, Instant};
Expand Down
3 changes: 1 addition & 2 deletions example/src/top.rs → alcova_examples/src/top.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::RootTemplate;
use actix::{AsyncContext, Message};
use actix_web::{web, Responder};
use alcova_macros::LiveTemplate;
use liveview::{
use alcova::{
LiveHandler, LiveMessage, LiveSocketContext, LiveTemplate, LiveView, LiveViewContext,
};
use std::{process::Stdio, time::Duration};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 class="mt-4 text-xl font-bold text-gray-800">Rust LiveView Autocomplete</h1>
<h1 class="mt-4 text-xl font-bold text-gray-800">Alcova Autocomplete</h1>

{{ if true != !(@selected.len() > 3) }}
Well thats a lot of fruit!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 class="mt-4 text-xl font-bold text-gray-800">Rust LiveView Demos</h1>
<h1 class="mt-4 text-xl font-bold text-gray-800">Alcova Demos</h1>

<ul class="list-disc text-lg font-medium">
<li><a href="/fruit" class="text-blue-500 underline">Fruit Autocomplete Demo</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<head>
<meta charset="utf-8">

<title>Rust LiveView Demo</title>
<meta name="description" content="Rust LiveView">
<title>Alcova Demo</title>
<meta name="description" content="Alcova Demo">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions alcova_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "alcova_macros"
version = "0.1.0"
authors = ["Connor Brewster <[email protected]>"]
authors = ["Connor Brewster <[email protected]>"]
edition = "2018"

[lib]
Expand All @@ -11,6 +11,5 @@ proc-macro = true
[dependencies]
syn = {version = "1.0", features = [ "full" ] }
quote = "1.0"
alcova = {path = "../alcova"}
proc-macro-error = "1.0"
proc-macro2 = "1.0"
File renamed without changes.
26 changes: 14 additions & 12 deletions alcova_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
extern crate proc_macro;

use alcova::{
parse_template, BinaryOperator, CodeExpression, Expression, Parser, Pattern, TypePath,
};
mod ast;
mod parse;

use ast::{BinaryOperator, CodeExpression, Expression, Pattern, Template, TypePath};
use parse::{parse_template, Parser};
use proc_macro::TokenStream;
use proc_macro_error::{abort, proc_macro_error};
use quote::quote;
Expand Down Expand Up @@ -95,25 +97,25 @@ fn impl_live_template(ast: &syn::DeriveInput) -> TokenStream {

#[automatically_derived]
#[allow(unused_qualifications)]
impl liveview::LiveTemplate for #name {
fn render(&self) -> liveview::RenderedTemplate {
impl alcova::LiveTemplate for #name {
fn render(&self) -> alcova::RenderedTemplate {
use std::convert::TryInto;

liveview::RenderedTemplate {
alcova::RenderedTemplate {
slots: vec![
#slots
]
}
}

fn changes(&self, old_template: &Self) -> liveview::Changes {
fn changes(&self, old_template: &Self) -> alcova::Changes {
use std::convert::TryInto;

let mut changes = vec![];

#changes

liveview::Changes { changes }
alcova::Changes { changes }
}
}
};
Expand Down Expand Up @@ -370,15 +372,15 @@ fn generate_match_arm(
}
}

fn generate_slots(template: &alcova::Template) -> Result<proc_macro2::TokenStream, &'static str> {
fn generate_slots(template: &Template) -> Result<proc_macro2::TokenStream, &'static str> {
let mut tokens: Vec<proc_macro2::TokenTree> = vec![];

for expression in &template.expressions {
let value = generate_expression(expression, "self");
match expression {
Expression::Literal(_) => {
tokens.extend(quote! {
liveview::Slot::Static(#value),
alcova::Slot::Static(#value),
});
}
Expression::CodeBlock(_)
Expand All @@ -387,7 +389,7 @@ fn generate_slots(template: &alcova::Template) -> Result<proc_macro2::TokenStrea
| Expression::IfLet { .. }
| Expression::Match { .. } => {
tokens.extend(quote! {
liveview::Slot::Dynamic(#value),
alcova::Slot::Dynamic(#value),
});
}
}
Expand All @@ -396,7 +398,7 @@ fn generate_slots(template: &alcova::Template) -> Result<proc_macro2::TokenStrea
Ok(tokens.into_iter().collect())
}

fn generate_changes(template: &alcova::Template) -> Result<proc_macro2::TokenStream, &'static str> {
fn generate_changes(template: &Template) -> Result<proc_macro2::TokenStream, &'static str> {
let mut tokens: Vec<proc_macro2::TokenTree> = vec![];

for (i, expression) in template.expressions.iter().enumerate() {
Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions liveview/Cargo.toml

This file was deleted.

12 changes: 0 additions & 12 deletions liveview/src/lib.rs

This file was deleted.

Loading

0 comments on commit 75cccda

Please sign in to comment.