shopr

Check-in [5cf6b89eed]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Continue bringup; start fleshing out styling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:5cf6b89eeda0aced88c286c3be4c23f66da089fade1762b2cc785f873ab327c6
User & Date: vandys 2019-06-20 23:54:17
Context
2019-06-21
03:52
Start cleaning up the CSS layout check-in: cdfd2f0ef7 user: vandys tags: trunk
2019-06-20
23:54
Continue bringup; start fleshing out styling. check-in: 5cf6b89eed user: vandys tags: trunk
22:36
Bringup check-in: 9f66b65036 user: vandys tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to css/shopr.css.

1
2
3
4
5
6




7
8

9
10
11
12
13

14
15
16

17
18
19

20
21
22
23
24
25
26
27
28
body {
 background: LightBlue;
}
div {
 width: 100%;
}




#items > span {
 flex-grow: 0;

}
.isel {
 flex-grow: 1;
}
.clR {

 background: pink;
}
.clG {

 background: LightGreen;
}
.clY {

 background: yellow;
}
#scrlists2 > span {
 background: pink;
 font-size: large;
 border: 3px solid black;
 border-radius: 6px;
 padding: 4px;
}






>
>
>
>


>


|

<
>


<
>


<
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20

21
22
23

24
25
26
27
28
29
30
31
32
33
body {
 background: LightBlue;
}
div {
 width: 100%;
}
#items {
 display: flex;
 flex-wrap: wrap;
}
#items > span {
 flex-grow: 0;
 min-width: 15px;
}
.isel {
 flex-grow: 1fr;
}

#items > span:nth-child(3n+1) {
 background: pink;
}

#items > span:nth-child(3n+2) {
 background: LightGreen;
}

#items > span:nth-child(3n+3) {
 background: yellow;
}
#scrlists2 > span {
 background: pink;
 font-size: large;
 border: 3px solid black;
 border-radius: 6px;
 padding: 4px;
}

Changes to get.py.

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
..
77
78
79
80
81
82
83
84
	# Logged in?  (This also verified that self.vals{} is there.)
	if not self.authenticated():
	    return True,self.send_error(403)

	# Known list?
	approot = self.server.approot
	nm = urllib.unquote_plus(pp[1][:-5])
	pdb.set_trace()
	l = approot.get_list(self.uid, nm)
	if l is None:
	    return True,self.send_error(404)

	# Wait for new revision?
	#
	# Note, we give them an update unless they say that
................................................................................
	#  from before this server restarted (and started counting
	#  gens from 0 again).
	gen = self.vals.get("gen", -1)
	if l.gen == gen:
	    l.await_gen()

	# How the list looks now
	return True.self.send_json(l.as_json())







<







 







|
61
62
63
64
65
66
67

68
69
70
71
72
73
74
..
76
77
78
79
80
81
82
83
	# Logged in?  (This also verified that self.vals{} is there.)
	if not self.authenticated():
	    return True,self.send_error(403)

	# Known list?
	approot = self.server.approot
	nm = urllib.unquote_plus(pp[1][:-5])

	l = approot.get_list(self.uid, nm)
	if l is None:
	    return True,self.send_error(404)

	# Wait for new revision?
	#
	# Note, we give them an update unless they say that
................................................................................
	#  from before this server restarted (and started counting
	#  gens from 0 again).
	gen = self.vals.get("gen", -1)
	if l.gen == gen:
	    l.await_gen()

	# How the list looks now
	return True,self.send_json(l.for_json())

Changes to items.py.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	self.name = name
	self.items = []
	self.gen = 0

	# Load any existing state
	db = self.get_db()
	c = db.cursor()
	c.execute("select name,idx from items where list=?", lid)
	for tup in c:
	    iname,idx = tup

	    # Deleted items shouldn't be in the DB
	    assert idx >= 0

	    # New item, with the saved generation value
	    i = Item(self, idx, iname)


	c.close()
	db.close()

    # Return a DB connection
    def get_db(self):
	return sqlite3.connect(self.approot.dbname)
................................................................................
    def await_gen(self):
	sema = threading.Semaphore(0)
	self.waiters.add(sema)
	sema.acquire()
	# Resume here after next_gen()

    # A JSON wrap-up of our content
    def as_json(self):
	items = []
	res = {"name": self.name, "items": items}
	for i in self.items:
	    # Don't share deleted
	    if i.deleted():
		continue
	    items.append(i.for_json())
	return json.dumps(res)

class Item(object):
    def __init__(self, l, idx, name):

	# Our parent list
	self.parent = l








|








>







 







|







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	self.name = name
	self.items = []
	self.gen = 0

	# Load any existing state
	db = self.get_db()
	c = db.cursor()
	c.execute("select name,idx from items where list=?", (lid,))
	for tup in c:
	    iname,idx = tup

	    # Deleted items shouldn't be in the DB
	    assert idx >= 0

	    # New item, with the saved generation value
	    i = Item(self, idx, iname)
	    self.items.append(i)

	c.close()
	db.close()

    # Return a DB connection
    def get_db(self):
	return sqlite3.connect(self.approot.dbname)
................................................................................
    def await_gen(self):
	sema = threading.Semaphore(0)
	self.waiters.add(sema)
	sema.acquire()
	# Resume here after next_gen()

    # A JSON wrap-up of our content
    def for_json(self):
	items = []
	res = {"name": self.name, "items": items}
	for i in self.items:
	    # Don't share deleted
	    if i.deleted():
		continue
	    items.append(i.for_json())
	return res

class Item(object):
    def __init__(self, l, idx, name):

	# Our parent list
	self.parent = l

Changes to js/shopr.js.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function show_list(ls) {
    // Clear old list display
    while (items.firstChild != null) {
	items.removeChild(items.firstChild);
    }

    // Display received items
    for (let i = 0; i < ls.length; ++i) {
	const l = ls[i];

	// Red/Green/Yellow tappables
	const s1 = document.createElement("span");
	s1.onclick = () => item_click(i, 0);
	const s2 = document.createElement("span");
	s2.onclick = () => item_click(i, 1);
	const s3 = document.createElement("span");
	s3.onclick = () => item_click(i, 2);

	// The text goes in the one selected
	if (l.idx == 0) {
	    s1.textContent = l.name;
	    s1.style.class = "selected";
	} else if (l.idx == 1) {
	    s2.textContent = l.name;
	    s2.style.class = "selected";
	} else {
	    s3.textContent = l.name;
	    s3.style.class = "selected";
	}

	// Add to DOM
	elems.appendChild(s1);
	elems.appendChild(s2);
	elems.appendChild(s3);
    }

    // Show list of items
    setcur(scrlist);
}

// Display the current list







|
|












|


|


|



|
|
|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function show_list(ls) {
    // Clear old list display
    while (items.firstChild != null) {
	items.removeChild(items.firstChild);
    }

    // Display received items
    for (let i = 0; i < ls.items.length; ++i) {
	const l = ls.items[i];

	// Red/Green/Yellow tappables
	const s1 = document.createElement("span");
	s1.onclick = () => item_click(i, 0);
	const s2 = document.createElement("span");
	s2.onclick = () => item_click(i, 1);
	const s3 = document.createElement("span");
	s3.onclick = () => item_click(i, 2);

	// The text goes in the one selected
	if (l.idx == 0) {
	    s1.textContent = l.name;
	    s1.classList.add("isel");
	} else if (l.idx == 1) {
	    s2.textContent = l.name;
	    s2.classList.add("isel");
	} else {
	    s3.textContent = l.name;
	    s3.classList.add("isel");
	}

	// Add to DOM
	items.appendChild(s1);
	items.appendChild(s2);
	items.appendChild(s3);
    }

    // Show list of items
    setcur(scrlist);
}

// Display the current list