Welcome to Book Club with Jeffrey Sachs. I am absolutely delighted and thrilled to have two colleagues and superstars on today for a discussion of a wonderful new book. First, Professor Richard Laird, Lord Richard Laird of the House of Lords of the United Kingdom, who is one of the world's gurus on our topic today. He is a professor emeritus at London School of Economics. I take emeritus to mean just filled with merit because nothing slows down with Richard in the slightest. He is the founder-director of the Center for Economic Performance and now leads LSE's Center Program on Well-Being, which is the topic of our discussion. And another dear friend and superstar in the area of well-being and happiness is Professor Jan Amonwell-Deneb, who is at Oxford University and he directs Oxford's Well-Being Research Center. And he studies our topic well-being in many, many different ways, well-being in the workforce, well-being in the environment. And both Professor Laird and Professor Deneb are co-editors with me, I'm happy to say, in the World Happiness Report. So after today's podcast, you will all get online and look at the 2023 World Happiness Report. This is an activity that Richard inspired in many, many important ways for all of us more than a decade ago to get started. Now, today we're talking about really a fantastic book, so I could not recommend it more strongly. It's a wonderful balance of a thorough and sagacious, wise overview of the topic of well-being and how to achieve it, and with a lot of just beautifully snuck in technical details. So you learn a lot about statistics and econometrics even and inference and avoiding pitfalls and reasoning. So it's actually a book that goes well beyond the topic of well-being, science and policy, which is the subtitle. It really goes to good reasoning and a logical approach to this issue so that we can understand what the evidence is. And by the way, one of the reasons I like it so much, there are many reasons. It's a terrific book, and as far as I know, it's really the first textbook of its kind, which is a thorough introduction, really smart and wise of this whole topic. The first textbook I would say in the past 2,300 years, because there was a very good textbook written around 330 BC by a really good researcher on this topic, Aristotle, in Athens. And one of the reasons, by the way, for both of you that I like this so much is that your cable of contents actually follows almost a risk-Athelian approach, because Aristotle wrote the first textbook on this topic. It's called the Nicomachian Ethics. Nicomachus is the name of Aristotle's son.  It seems to have been collected by his students as lecture notes. It's sometimes said that he wrote it as a kind of self-help guide for his son. Here's how to be happy, but your cable of contents, which is fantastic, really thoughtful and comprehensive, takes the approach that Aristotle takes, and that's what we're going to take in our discussion. It starts out with the question, what is happiness? And then it goes right to the question of human nature, which is actually pretty core Aristotle, what makes us tick. And then you go through all of the different dimensions of our lives, actually, because they all play a role. And then you end up with what government can do, and just not to talk any longer, just to say that Aristotle finished his textbook on well-being, the Nicomachian Ethics, by saying, now we go to the next volume, politics. So he wrote, actually, a companion volume on politics, what should government do? You have that in three chapters, and with, I'd say, more mathematical precision than Aristotle. But really, you're in a long line of 2,350 years of tradition, so I congratulate you. And I think it's the finest textbook on this subject for at least a couple of millennia, so thank you for that. So let's get into it. Richard, what is the case for well-being? That's the opening of the book. Yes. Well, of course, you have to have some overarching objective if you're making difficult choices between alternatives. It applies to the government deciding how much to spend on education, or the transfer, or whatever, big difficult choices. It also applies to us. We've got to make big choices, what jobs to do, how to conduct our family life, and so on. There's got to be some overarching objective against which you measure the value of all the alternatives. And we say that it is the well-being of the community. That's the overarching objective. How do we get there? Well, you might say, well, wealth is very important, or the health is very important, or the freedom is very important. I would say, well, why don't we ask why these objectives are important? Why is wealth important? Well, it enables you to have a more enjoyable life. Why is freedom important? Because slavery makes you feel terrible. Why is health important? If you're sick, you feel terrible. Then you say, why does it matter how we feel? You can't give an answer. There's no answer. It's self-evident. It's self-evidently the thing which matters most, and other things matter because of how they contribute to it. So that's the argument. And I think it is critical if people object to it that they face up to the issue, well, what is your alternative criteria to this? And you'll find that none of the people who object to this are able to provide an alternative, in which case they're just not able to answer the basic question that's requiring answering. So that would be my justification for the case. Now then you come, of course, to can you measure it? We say, yes, you can measure it. You can ask people questions. This has got a lot of information content. We know what people say about how happy they are. This is one of the best predictors of how long they'll live, for example, as good as a medical diagnosis, good predictor of how they'll vote, how productive they will be, whether they'll stay the course in their job or even their marriage. So there's a lot of information content in these answers. So it's not only, as I was saying first, a desirable criterion. It's also a feasible criterion. And we now know a lot about what causes it. And until we knew what caused it, there was a bit of a difficulty in applying it. So as you were saying, Jeff, it goes back 2,300 years, but it got a big revival in the 18th century Enlightenment. And of course it influenced people, but it got undermined in the 20th century. Well, before we get there, we're going to cover all those grounds, but Yana Manuel, if you want to come into add to that. Well, on the measurement piece, because that's obviously where the rubber hits the road and where as empiricists, I mean, Jeff, you and other economists, we want to be able to show things and provide evidence. So we need the data. And I think that's been, I mean, it's been a long time since Aristotle and even the Enlightenment. But I think it's the data revolution that has really brought a lot of new life and will allow, I think, the field of well-being and what is the good life to take it to a whole new level, I think, is the availability of data. So the fact that the Office for National Statistics is measuring this as part of population statistics, the fact that the OECD is pushing this, the fact that the United Nations recommends this to be measured as a complement to GDP. So there's now these wonderful data sets and that allows, I think, us to take the evidence to the next level. So how we measure it is actually critical. As Richard says, I think there's an emerging consensus that we can measure this. The internal validity of the measure, the external validity of the measure, as Richard highlighted. And maybe if I can build on Richard on the measurement before we move on to other exciting topics, it's, well, how do we actually measure it? And then, Jeff, this will be very familiar to you because one of the ways to measure it is obviously by asking people, which is the one way to ask it, the one way to find out whether people feel good is obviously by asking them. And they are the ultimate sovereign on this. Well-being is in the eye of the beholder. It is not me who can decide whether Jeff is happy.  And I have to ask you whether you're happy. And I have to take that for granted. And then reverse engineer to see, well, what helps explain variance in between Jeff and his family, et cetera. And what's interesting about these measures of asking people is that, in fact, if you are asked to predict how a friend or someone else you know is or isn't happy, you actually come up pretty close when they report or when you look at them. So there's something real in this because it goes actually both ways. Absolutely. Yeah. So the external validity of these measures that have been studied, thanks to many, many psychologists from the 80s and the 90s onward, we owe a lot to people like Ed Diner and Marty Seligman and a whole crowd around positive psychology for digging into do these measures, these feelings, these subjective well-being, do they hold signal and not just noise? And you're actually right. There's a lot of value to these numbers. And one thing that you emphasize and that is key to this whole literature and this whole field of study, I should say, is two basic different kinds of subjective measures. So I think it would be very good to explain that. And possibly a third, which then links even more closely to Aristotle. So the first one, the one that we've chosen for the World for Our World Happiness Report, is the evaluative dimension, which is essentially satisfaction with life or the cantor letter, a more sophisticated version of that. And just explain what do people answer in trying to get at that? Yeah. So the World Happiness Report, as the three of us know very well, are friends at Gallup who do representative surveys of populations around the world and would ask the question, imagine a ladder with the top rung being 10. And imagine that that is the best possible life for you. And the bottom rung, zero, is the worst possible life for you. Where do you think you stand nowadays on that ladder of life? So that's the cantor ladder. And that's essentially evaluating the quality of your life through your own eyes and how you experience it. That's the evaluative approach to well-being. And then as you as you rightly noted, there are all the other ways of measuring well-being, which then come at it from a more emotional or affective way, which would then be say, Jeff, are you happy right now? Or are you experiencing worry yesterday or today? And when we ask about yesterday, it's really just to get like a day and not be beholden to a specific time in the day. So those are the affective measures. And then there's a third sort of dimension. It's a slightly more debated. In the book, we dig into this a little bit, which comes closer to what is then called oedimonia, referring back to Aristotle, which in the Office of National Statistics gets translated as or a question as, do you find life worthwhile? So notions of purpose, worthwhile meaning, which has a virtue element to it. So is what you're doing, is your life worthwhile also to others or meaningful more generally? So that is somewhat debated whether that is sort of a third angle onto subjective well-being. Or something like part of the first approach. Precisely, precisely. Yeah, because you could even say the first approach is a little bit reflection, basically on the whole, how's your life going?  So the emotional versus this longer term. And I think it's interesting to go back to what Richard was saying just a moment ago. Aristotle argued on the same basis as both of you that, well, if you think about, is it wealth? Aristotle said, well, yeah, wealth is okay. It's not bad, but it's for something else. What's the one thing that isn't for something else but is for itself? And that's your well-being, which, as you say, he called the ebdomonia. Maybe it's the ancient Greek pronunciation or eudomonia, as we say right now. And then the question is all of these measurements. And boy, it is really a kind of revolution because Aristotle didn't have one data point. He was just an incredibly clever observer and thinker and very logical, but without a data point. Whereas now we have these Gallup surveys, which is really the basic measurement that you're looking at in this book. In 150 countries or so, and every year, and this is incredible actually to have that kind of information available. And it is for the first time in history that this is being systematically collected in a way that can be compared within a country in a given time or across time within that country or across country. And so it's really remarkable. Well, surely it's the best description of what is the human situation on the planet. I love, we have right at the beginning, a diagram of the distribution of happiness in the world. And you've got averages in Scandinavian countries on a scale of 0 to 10, something like 8, nearly to 8. And you've got averages in countries like Afghanistan and South Sudan of 3. It's just incredible, the spread. And you can see that we're capturing in this something that is really corresponding to human experience. And it's never been done before. And in the 2023 report, people can find it online. But the top three reported countries of being on the ladder near the top rung, near rung 10 is Finland, Denmark and Switzerland. And the three countries on the lowest rung reported, as you just said, the very bottom is Afghanistan. And we know that's a place that has just suffered terribly from everything that can go wrong has gone wrong. And Rwanda and Zimbabwe are the third from bottom, second from bottom, and Afghanistan. So you really see a spread that makes sense and that is rather consistent over time. There are changes, but when the changes occur within a country, you can say, oh yeah. Well, they became happier because there's some economic development going on or more life expectancy. They became sadder because they're at war now. War has broken out again. And so you really can make sense of it. So I wanted to go to the second big theme of the book, which I think is terrifically put, which is you distinguish in three chapters, three big headings to think about our well-being, our behavior, you say, our thoughts, how we think about life, and our genes and our physical natures, personality and so forth. So could you discuss, these are kind of the big background factors and then you take a deep dive into what these mean. But I think we should talk about these three big factors that one is what we're doing in our lives and our society. The second is how we're thinking about that. And the third is something maybe that we've inherited that we're personality tending towards being happy or tending towards being, oh my God, I'm worried, whatever it is. So could you take us through these three big headings? Yes, maybe a good place to start is with the Nobel address by our friend Daniel Kahneman, the psychologist who was awarded the economics prize, because what he had to say was very relevant to how we should think about political economy and how our lives should be organized. Was it just enough to have laissez-faire, for example, leave everything to individual choice? So I think it's almost his first statement is economists believe that people are rational, consistent and selfish. And psychologists don't believe that either of them. If we take the rational thing, you've got obvious counter examples. You've got people who suffer from addiction, who would like to stop doing something, but they can't stop doing it. Then you've got people who think that they'll gain something enormously from some change. They don't know that they'll adapt to it and that they will, in fact, have spent a lot of money on a bigger house. In fact, they don't feel any different after three months because they've got used to it. Then you've got people who are extraordinarily gullible, if you like, according to how a choice is presented to them. For example, are you going to opt into a pension plan? If the choice is presented to you, you have to say if you want to opt in. They find, typically, for example, in one of these cases, something like 20% opted in. If you have to say, I'll opt in. If on their hand, you're told you're in this pension plan, but you can opt out, only about 20% opted out, so that 80% are opted in. So completely inconsistent decisions, depending on the some tiny little way in which the question is asked and so on. The rationality is certainly not their consistency, not their. And then are people selfish? Well, actually, they're not that selfish. There's a selfish element in everybody, but there's an extremely unselfish element in everybody. We couldn't really hope to have moral behavior from people unless they had some strong feeling of sympathy for other people. They experienced other people's pain. And they didn't like to see other people in pain. They liked to help other people. And incidentally, going back to your previous thing about eudaimonia, they also got some satisfaction from helping other people. So we need a much wider view about human behavior, which of course also includes the obvious point that society, the way in which it steers things like pension plans or the whole setup of social support can enormously influence people's happiness. Well, then we go on to suppose things have happened to people. How does that actually affect their well-being? And one of the great discoveries of the last 50 years has been that the way people think about their experience has a huge effect in intermediating between the experience and the well-being that results. I'm going to insist, not discovery, but rediscovery, because the Stoics knew it. I'm quite happy with that. Marcus Aurelius knew it as Emperor in his meditation? Quite happy with that. But I think that it's a combination of ancient wisdom, obviously, Stoics, Buddhism, many things, with modern cognitive behavioral psychology, positive psychology, are giving us the tools to improve people's well-being through helping them think more positively and focusing more positively on the situations in which they find themselves. And Richard, if I may say, you've been really pivotal and transformative in insisting on mental health interventions, especially by its technical term, cognitive behavioral therapy, helping people to think better about their situation. And so this is a case not of happy people being happier, but of people who are desperately unhappy or suffering from terrible anxieties or other really debilitating conditions being able to be helped to think more clearly. If I could ask you to say something about that, because you've really been championing that for 20 years now, and people are listening. One of the points you've made as an economist championing this is, this doesn't cost very much, and you really get a big impact. So that's been very persuasive. Yes. Well, we started on this about 15 years ago, and we made the case to the British government that there were evidence-based therapies, not only CBTs that we call... Cognitive behavioral therapy for people. But interpersonal therapy, brief psychodynamic therapies, which have strong impacts on both depression or anxiety disorders like OCD, PTSD and so on. Panic attacks, phobias, really able to change lives. Not of everybody is treated, but in the trials, the success rates are over 50%, and we have found that in the service that we got the government to roll out, we are also getting success rates of well over 50% of people being relieved of symptoms that they've had for 20 years in many cases. So there's a huge way here in which we can help people, and I think it's something which benefits enormously from being well-organized, and I think we're able in this program to organize it in a way which is now being copied in seven different countries. So you have to have a very good training program to train people in these evidence-based therapies which are recommended by the health authorities. And then you have to have really proper, well-organized services with very good supervision, but also, which was secret of how success, really, measure the outcomes and prove, therefore, you can prove that the money is not going down a black hole, that it's actually achieving something. So this has been a huge improvement, I think, in the attitude which governments have but also population have had to psychological therapy that we can show that it's not people going round around circles as some people have criticized some therapists for doing. It is producing forward movement. Jeff, if I may, you mentioned at the beginning of the question, there's also a biological genetic. Yes. And I think it builds well on what Richard is saying. Yes, we can try and help people think better and that then improve their well-being. We have to accept that there is a stable component to well-being as well, often called a set point, though that language is not always accepted. And the set point is essentially a genetic predisposition, if you will. And the way we figure this one out, and I've contributed a little bit to this line of the research, is through twin studies. It's actually very intuitive. So we've got data sets where we've got, say, 600 couples of non-identical twins and another 600 or so couples of identical twins. And then you look at their responses to life satisfaction of the cantraladder. And what you find is that the identical twins, the covariance or the correlation between their responses is a lot stronger or quite a bit stronger than it would be between non-identical twins. Actually, you point out something even stronger than that, which is that identical twins raised in separate households are much closer than non-identical twins raised in the same household. Yeah. So it's really something. There's something there. And when you do these modeling, and then you sort of reverse engineer to see what extent of the variance between people's well-being is explained by genetics, it's about a third of all of the variance. So later on in the book, we'll talk about employment and marriage and age and what have you. And all of that has some impact. And it's typically one, two, three percent of the R squared of the variance being explained. But genetics as a whole explains about a third of the lot. Yeah, which is a lot. I want to get to the parts that are. Sorry, Richard. I just wanted to point out that there's no sense at all in which if something originates because of a genetic predisposition, that it's more difficult to change that than if it originates from a previous experience. Both of these things can be equally altered by appropriate psychological therapies or better experiences subsequently. Yeah. So, Jeff, the point here is genetic predispositions are not deterministic. Right. You're not locked into suffering or locked into happiness. All these other factors still matter for anybody, an identical twin or a pair and so on. I want to say as we move to the next part, which is really one wonderful chapter after another of the social and individual contributors to well-being. Again, I have to say I feel a lot of resonance of what science is showing with what Aristotle observed and wrote, because he didn't say everyone's rational and he didn't say everyone's irrational. He said, it's hard. We should try to think properly. Not everybody does. And he didn't have the term for addiction, but the Greek term akratia is you don't have self-control. So, he more or less describes the phenomenon and says we should be end-cratic, meaning with self-control, we should use our minds to help us tame our surging otherwise uncontrollable desires that could do a lot of harm to people. So, he had a kind of model of addiction or not addiction, but it was mainly saying, you know, at least we can help people and groups and even political communities move to well-being.  So, of course, it shapes our well-being, unemployment, your work relations and so forth. So, there's a lot there, and actually every chapter is very rich in practical evidence. There is no one key to happiness. It's not, if you just think right, you'll be happy. If you're just rich, obviously not. If you have a good job, it helps, but it doesn't guarantee and so forth. So, how can we take this kind of overview? Is there a way to summarize the broad mix of factors? You have a lot of diagrams showing many different things affecting happiness. How could we give an overview of all of these factors feeding in? Well, there are two ways in which you can go at this. If you've got a population of people whose happiness is varying, you can try and say, well, some of these people are in a really bad state suffering from what we might call misery below a certain level of life satisfaction, as Jan was putting it. You could then say, what are the factors that are the main factors which are accounting for people being in that state?  A very simple question, have you ever been diagnosed with mental health problems of depression or anxiety? It's a very simple question. That's the biggest thing. Physical illness is also a big thing, chronic pain. Having no partner, which is easy to measure, loneliness. Loneliness or divorce or other things can cause people to suffer. And after all of those factors is coming poverty. This is in rich societies, but it seems to be quite similar the power of poverty to explain the most miserable sections of community even in poorer countries. There are so many factors, personal factors, which I feel governments in every country now have the tools to influence. They can influence what people's mental health is. They can influence whether they are abandoned and isolated, as well as whether they are poor. And we're going to have to have more concentration on health policy, on social policy, as well as economic policy from governments in every part of the world. The second question you could ask is, well, what's explaining the whole spread of happiness, including the upper reaches? It turns out they're the same factors. So asking the question, what are the main causes of misery is a pretty good way into this subject. Since economists generally start with the question, well, of course it's income. Because when we train our students or read our introductory textbooks, and I remember it was many decades ago, my introductory course I was told you have a financial budget constraint and that's going to determine what you can buy and that's going to determine what we call your utility. And there's some truth to it, but one of the most important findings, I think, and Richard, you've also done really interesting and important statistical work on this, is what's called the diminishing marginal utility of money. And maybe, Anna Manuel, could you just explain that concept and what's the implication of it? Thank you, Geoff. And Richard has a cool paper in Journal of Public Economics trying to get a measure for diminishing marginal utility of income. But in essence, it's the notion that at higher levels of income or household wealth, any additional dollar or pound or euro will have a lower and lower marginal impact on your well-being. And that tapers off pretty quickly. So there's obviously a contentious debate. This is typically what well-being economists would be looking at, is does money make you happy? And there's no hiding behind the fact that at lower levels of income, adding 5,000 pounds or 5,000 dollars to somebody who makes 20,000 is going to have a measurable positive impact on their life satisfaction. But add that 5,000 dollars to somebody who makes 150,000 or 250,000, it has no impact whatsoever anymore. And so there is definitely sort of a leveling off and depending on which measure you use, evaluations or emotional well-being metrics, that sort of satiation point or that leveling off happens a bit sooner or a bit later. And so Danny Collin and Agus Deed and Richard myself and others have been working on this. One point I wanted to make, which is one paper and Roswell and I did put that question that economists always look at on its head. So rather than asking the question, does money make you happy? We said, well, maybe richer individuals were happier to begin with. So there's maybe even a reverse causality. So whatever you're finding as a coefficient on money to happiness may have been driven by happiness in the first place. And lo and behold, guess what we found? When you look at the well-being, licensed action and emotional questions to adolescents, like we have data like big panel studies out of the US, when they're 14, 16, 19, 21, you guess what? Their licensed action and well-being metrics are highly predictive of their earnings later on. So whatever you find in your coefficient of money making you somewhat happy, well, I could have been because you were happier to begin with. So it puts you more doubts on that question of money to happen. And I find myself, I find it so striking that even us economists have always thought, have taken societies, like have taken it on as if it can only be one direction, money to happiness, but never, I mean, our 2012 P&E S paper was the first one to really put this properly on its head and ask the question, wait a second, how about reverse causality here? It's also very interesting. I'm going to invoke the classics again that, you know, there is a view in some religions and in some philosophies like stoicism that it's kind of all in your head or most of it. And I always liked Aristotle saying, you know, money is not everything, that's not happiness, but it sure helps to have enough so that you're not suffering. So he really, he didn't express it as the diminishing marginal utility of money, but he said, you need enough and in fact implicitly said you need enough to be able to be a philosopher, you know, to have time to think, to have time for leisure, not to be completely overwhelmed with trying to just put food on the plate. And so he had that idea and I always liked that because there are always extremes in everything we're talking about. One extreme is it's all money and I think this whole field that you're leading has moved the discussion away from that very naive idea, but that idea was around and it's still in a lot of people's heads. I just got to get rich, that's the only way I'm going to be happy. On the other hand, there's the other extreme which is, you know, it doesn't matter at all. It's just, I can accept anything and life doesn't work that way either. It's really something in the middle. And it also belies one of the fears about this whole line of study and whole line of approach, which our dear friend and colleague and Nobel laureate Amarche Sen always worried about, which is, well, you'll talk poor people into being satisfied. And that's what's dangerous about this because, you know, the poor person will be told, you should just be satisfied, but it's not like that either really. Poor people want enough that they're financially comfortable. Now, you raised a very, very interesting point and there's a whole discussion about it in the text, which is that many things contribute to happiness, but happiness contributes to many practical things as well. And you've just mentioned one that if young people are happy, it turns out that's not only predictive, but probably causal, that they're going to be more successful later on because they'll take on more challenges, they'll invest, they'll be more sociable, they'll be more aspirational. But you point out many areas where the causation is not to happiness, but from happiness to better outcomes. And I wonder if you could just take us through a few of those because they're fascinating. Yeah, well, Jeff, remember in 2014, I think in our world, happiness support, we sort of rounded up all of the evidence and we call it the objective benefits of subjective well-being. And that kind of is a good segue, I think, into this material. But you're absolutely right. So there's a lot of these positive spillover effects of being able to raise well-being. We mentioned one, doing better in sort of job outcomes and the salaries attached to it later on. And your intuitions were spot on and we were able to find the ways in which and why. That is like people become more sociable and more opportunities coming their way, they're more likely to be promoted if they are in a positive vibe around them. Other elements down the line consequence would be better health. Richard mentioned longevity and better health behaviors, more pro-social behaviors. People who are happier are more likely to donate, more likely to volunteer their time, et cetera. The one that I focused a lot of time on and implicitly today, online on management signs, the papers finally come out is the example of the link between how you feel and how productive you are at work right then. So we've for the first time been able to causally nail through a massive field experiment in collaboration with British Telecom to show that if you feel better from one week to another, that has a massive impact on, say, weekly sales. How could you do that? That sounds like a... Jeff, I'll be very brief. The way we've been able to do this is by leveraging the weather differences around the call centers of BT. So you're going to love this. It took us three years to get to causal evidence and the referee's really pushing on this. And it's not just the weather differences around the call centers when the call center employees came in that influenced their well-being, which was the exogenous shock on them. In other words, if the weather is bad, people are down. We're down. And then if they're down, then you look at how productive they are. But in a way that the weather won't affect directly. Exactly. So the calls that were coming in from work around the country. Not about the local weather. But the referees pushed us one step further. It wasn't just the weather impact as the call center employees walked in to door that morning, the local weather. They forced us to go one step further. Also look at the exposure. So the 16 call centers, we had to nail down the extent of window coverage to see how the interaction between the weather that day and the exposure to it to improve the accuracy of the effects. When it was bad weather and there was a lot of exposure to it because it was lots of glass windows, the effect was stronger than it was bad weather and there was little exposure to the weather. And so we were able to... Anyway, you see where I'm heading with this. So it was quite something to nail this, but we're there. So there's now causal effects, feel evidence for the link between how we feel and how productive we are. Phenomenal. Richard, one of the things that you have been leading on like you to describe it is a kind of grassroots level effort to help people in communities to find higher levels of well-being in part by getting together to build social connections, trust networking and so on. One of the themes of Aristotle is that our relations with others, whether they're virtuous, trustworthy and so forth, actually raises our own well-being and this is a big theme of the textbook. Also describe how community plays a role in all of this and what the implications are for how we should think about this issue rather than one individual as a time, but actually in building community. When you started on the movement, let me just say a little about the movement, then we come to community in general, but we live in a largely secular age. So the ethics that used to come to people through religion are not coming on the back of that. They need to come on the back of something else. And we believe that that should be the great enlightenment ideal that the way you should live is to try and contribute whatever you can to the happiness of the world around you and so the driving force for that movement that you mentioned. And what is the name of the movement so people can look it up? It's called Action for Happiness, Action for Happiness. The pledge that all the members take is I will try to create as much happiness as I can in the world and as little unhappiness. And I think that's a really inspiring message coming from the enlightenment. And we're seeing in particular at the moment, adolescents and young adults, is terribly uncertain about what they should be doing in their lives. But this is an incredibly important and stabilizing message. But it's a message for all of us. So the question is, how can we live well? It's not easy to live a good, balanced and relatively unselfish life without some framework that helps keep you motivated. And that's the idea of Action for Happiness. People come together on a regular basis around the ideal of how they're trying to live. All of us imperfectly. And how we can be sustained in coping with our own inner demons and helping other people in their lives and maybe with some of their problems too. So people meet regularly, but having taken obviously some sort of course through which they learn the secrets how to live a good life which is satisfying to you and to the people around you. And now they have a textbook for that also. This course, Jeff, has been subjected to a trial. And these are the remarkable results that after this eight session course, two months afterwards, people are still as much happier as the results of the course as if they had found a partner for life or a job from being unemployed. So there's an awful lot that can be done. Not by experts teaching, but this is volunteer led. There are also, of course, very good courses online. But coming back to your more general point about community. Of course, we are social animals. Your friend, Larry Soto, I think, was the first person to use that. Zohan Politikan, as they said in the group. We are getting our enjoyment from interaction with other people. We are getting our support from other people. We're getting our sense of identity from other people. And it's been shown many times over that how long people live depends on the strengths of their social connections when they are measured earlier in their life. And the thing which, of course, is a way of expressing your commitment to the community is to volunteer your services to help in local associations, even sports clubs, or helping other people who are in trouble. One of the interesting things you point out is arts and sports are very real. Well, of course they are, but actually they show up empirically as very important builders of community. They do. We've just had a very interesting experience in the lockdown here because people were encouraged to volunteer to help people who were isolated doing their shopping, taking them to the hospital. And there was huge over-subscription of volunteers. And it was a random allocation who was asked to do the volunteering. And it was found that the people who did the volunteering increased their life satisfaction quite substantially relative to other people. We should explain to listeners that any time there's a random allocation, economists see an opportunity to study the effect of that. And so you have been able to use that to see whether those who were lucky to get into this desirable situation actually achieved a higher level of well-being. Yes, and they did. And they did. So this is one aspect of community that gives you an opportunity to help other people. As Adelaï Lama always says, I benefit as much as the people that I help when that happens. Let's turn to the conclusions of the book, which is government. Because you give a lot of assignments to government to say, you have to do things differently in view of all of this evidence. What are you doing chasing variables, GDP, or whatever it is, that when you could really be helping directly by measurement and then by policies to promote well-being in the society. And you show also the studies that show if governments do that, they actually benefit as well by focusing on well-being. Maybe you could describe that two-way result as we conclude the talk right now. Maybe Yannem Manuel to comment on that. You go first. I will. So yes, in two chapters, one called how government affects well-being and then the opposite direction, how well-being affects voting and political behavior, we sort of round up all the evidence. And it's quite striking that quality of government, whether it's government effectiveness, rule of law, regulatory quality, or control of corruption is very positively associated obviously with well-being. Maybe it will not come as a surprise. There's probably a lot of other covariates, but still there's definitely something very powerful about what governments can do about themselves to improve the well-being. And I think it's very important and striking. And I think probably everyone listening can feel it also. When our government's misbehaving, when it's cheating, when it's corrupt, you really feel bad, not only about that, but it really is depressing actually. I mean, it's very annoying. I couldn't agree more. And I'm literally looking at the graph on page 258 where we look at the quality of, you know, democratic quality of governments, whether it's voice and accountability or political stability, which kind of refers to the point you're making. And the correlation is just massive. And obviously Denmark, Sweden do very well. And then you've got places like, you know, Bangladesh, Tanzania, well, Tanzania is fine with others at the bottom. And you can tell it impacts negatively population well-being. But then when you turn it around, what I think is really ultimately going to get the policymakers interested in this, is there some... Or the politicians even more than the policymakers. The politicians is obviously their self-interest, which tends to be focused on staying in power or reelection. And what we found here is thanks to one fantastic work by George Warden, and Rich and I have contributed a little bit to that in later stages, is the idea that if you look at levels of well-being prior to elections from one sort of electoral period to another, you find that nothing, literally nothing, better predicts how the incumbent vote goes than subjective well-being, measures of life to the suction. And we compare and contrast that to the traditional stuff, like inflation and GDP and employment levels, even sort of ethnic mix of the local populations. And you find that, yes, these matter, but well-being, how people feel, is obviously how they interpret the outside world around them. These changes, economic and social, they interpret that as the crops hit up and they're subject to well-being, and that's what gets out on the vote. So as one of the cartoons in the book emphasized, it's not the economy's stupid, it's the well-being. Precisely, yeah. And it's really important. And that brings us to the 18th chapter, very important. And Richard, you talk about how government should think about what they're doing and think about it differently from what they're doing. Tell us what a well-being is. So going back to the Great Enlightenment ideal, we want governments to direct their policies to maximize the well-being of the population. And Thomas Jefferson said, the care of human life and happiness is their sole legitimate objective of government. Absolutely right. You can't think of any other provided the happiness is relatively fairly distributed. So we have been campaigning to try to get governments to make well-being that goal. Of course, some governments have started using this language as a well-being economy governments alliance which was led by originally New Zealand, now has Finland and other countries in it. And the idea should be that if you imagine a country with a given budget, how do they spend their money? They should be evaluating all the policy proposals that are coming their way in terms of the well-being generated per dollar of expenditure. That's the proper measure of cost effectiveness that we are pushing. In our own country here, we now have the leader of the opposition who may become the prime minister in two years. We don't know. He has said that he will require the Treasury, the Finance Ministry to evaluate all policies in terms of their effects on well-being as well as gross. So this could be an interesting experiment in really applying some of the principles in this book. But we're trying to promote this idea worldwide. We are involved, Jan and myself, in a new movement called the World Well-Being Movement, which is centered in Yans Institute, but the Worldwide Movement, to get countries to adopt well-being as their goal for their governments and, of course, as a major purpose also for any organization, be it a business or a school, because this is such a general principle. That's, I think, where we should be ending this conversation, isn't it, Jeff? This is something which overrides everything. It relates to everything the whole of life is involved in contributing to the well-being of the people. And therefore, if we think well-being as a goal, that is influencing how we should conduct every aspect of life. Well, this is a wonderful place to not end, but to take a pause. And for me to thank you, we've been speaking about well-being, science, and policy with Professor Richard Laird of the London School of Economics and Professor Jan Manuel Dinev. This is a wonderful, wonderful book. It's going to sit on the bookshelf next to the Nikomaki in Ethics and the Politics, and it's going to make a major contribution. And I'm sure that people all over the world are going to be reading it with tremendous benefit. So thank you both so much for the book and so much for the conversation today on Book Club with Jeffrey Sachs. It's been great to be together with you. Thank you. Thank you, Jeff. Bye-bye, everybody.


So ladies and gentlemen, it's 1 p.m., it's time for the session and I want to start with how was lunch? Great, that's kind of a great start. Okay, we're here today and we want to present on how to auto-generate your Drupal mobile app with PhoneGap is present by Jeff. Jeff Linwood. And me, Fabian Franz. I'm from Twellon and... I'm from Biscotti Labs. Okay, and yeah, this will be kind of a fun session, but it's also a beginner session. So if you're into fun, you can stay. But if you're kind of saying like and expecting some high level stuff going into code, deep level, then this is not the session for you and you have the chance to leave. But you will definitely miss something. But you'll see. The other thing is we would like to have the questions part at the end because the presentation flow is not designed to work with questions. Okay, everyone ready? Let's go. No, it's not my phone. Your client is calling. Hello there. Welcome to Drupal Web Shop LLC. What can I do for you? Hello there.  It works so great, it's fantastic. And we just want to get one step further. You know, it's all about apps today and we really want a mobile app. Well, before I give you an answer, let's figure out what you want us to build. So, chapter two, gathering requirements. First of all, after some conversations with the client, you find out that the requirements are, it should be a mobile application for Android and iPhone. It should be available in Apple App Store and Android Market. It has to be offline content that can be reached without network. And it should also just get the newest news that you put up on your website directly into the app so it needs to support online content. It should have native device features because your client really, really wants to use a camera. So, what could we use for that? I think let's do some research. Google is always something good to ask and let's just see what comes up. Oh my God, what is that? I think I'm pretty clueless now and I think we are really lost in the jungle. It's a movie by mobile application development. But fortunately, we do have a magic wand. And with this magic wand, we'll use it and we'll see what happens. So, are you ready? Are you prepared? Let's do it. Three, two, one, magic. That looks much better. So really, what we found out from our Google research is that there are certain kind of partitions that we can put in our mobile development. There's, of course, Drupal. It has a services module. It has an Android SDK called Dandy. The Drupal iOS SDK. Then there's those mobile frameworks like JQ Touch, Sancho, Ajax, JigFury Mobile. Of course, you got the native applications like your Facebook app, Google Maps, whatever. For this, you have the Android SDK with Java and the iOS SDK with Objective-C. And then there's also HTML5 with HTML export, responsive design, HTML manifest. And then there's Hybrid. And there, for example, you could use Titanium, PhoneGap, and the secret we will today will be the mobile app generator. So, now that we kind of have the solution space, the next part is we have to analyze those solutions. So, this will now be the really boring stuff. You can expect 50 minutes of boredom analysis, and it will be very dull. So, you can get up your laptop, start stacking emails, very, very dull. And really, really, really boring. Oh, really? No, of course not. Meet the mobile tournament 2012. This will be now really, really fast, and it will be just for fun. You can later check the slides online, we'll put them on after the talk, and then you can check what is there. It will be too fast to follow. But it's for the fun, and no one wants to have 50 minutes of analysis. So, if you are not into this kind of stuff, just ignore the next three minutes. So, let's meet the fighters. We have the normal Drupal site, the mobile Drupal site, the web application, and the native application. We have the hybrid, and we have the mobile app generator. And fight. We have the normal Drupal site, it's through Plista, and it comes in with techniques. It has menu, blocks, and views, and panels. But it's not mobile by default, it's always online, and it has no native features. No. Mobile Drupal site, Omega T. Omega T comes in with responsive design, mobile frameworks, HTML manifest, but it's always online, has no native features. Next one, please. We have the web application, JQ. But it's technique, it has data load via eJax. It features services module, mobile frameworks, animated transitions, but it's always online, it has no native features. Services can be really a little complicated. So, next one. And then we have the native application. It's native UI and native UI. It has techniques, native code for iOS, Objective-C, native code for Android with Java. But it could be rather complicated. The knowledge could really not be available in your shop. There are two different versions you have to program for, and you have this native UI. So, let's meet our next fighter, hybrid application, hybrics. It's a web application running on the device. It has phone gaps, services, mobile framework. It's offline and online. It has native features. It's for Android and iPhone. It has JS, CSS, and HTML5. We have... We have it filled in as you can see. But what exactly is PhoneGap? And so, what PhoneGap lets you do is you can make your mobile web site, your mobile web application using all the stuff that we've talked about here at DrupalCon with jQuery mobile, with responsive design, with Drupal themes, your HTML, your CSS, your JavaScript, but you get access to all these really cool smartphone features that you only get with a native smartphone app. For instance, using PhoneGap, you can actually take your mobile website and get it up on the Apple App Store. You can get it up on the Android Market. You can have all kinds of really cool native functionality. You can actually use the camera. You can take photos. You can record video. You can get access to the person's contacts on their phone if they let you. You can do all kinds of interesting things with accelerometers, compasses, gyroscopes. It's a really cool way of taking your existing web programming skills and turning that into a mobile app. And to talk a little bit more about how that all works and some of the native functionality, I'm gonna turn it back over to Fabian. Yeah, I'm giving you an example here now how this is working because really what Jeff found out is that people do not really know what is PhoneGap. Is PhoneGap jQuery mobile? Is it CSS? Is it JavaScript? What is this PhoneGap? What does it do? So here we have an example. We have written a JavaScript and it's talked to the browser and it says, hey browser, take a picture. And the browser answers, hey you, what's wrong with you? I can't take a picture. I don't know how to do that. And yeah, a browser can't take a picture at the moment. So, and this is where PhoneGap comes into play. PhoneGap is really putting in this component. You again ask the browser, could you please take a picture? And PhoneGap is answering you, okay. It asks the camera and it knows how to access all the cameras of Android, iPhone and Windows Mobile and the camera is asked to take the picture. The picture has gotten back to PhoneGap and PhoneGap gives this information back to the JavaScript. So, this should kind of make it more clear of what PhoneGap really is. It is a bridge that is extending the browser features so that it can do all this cool stuff. So, now that we've looked a lot about what I can do with PhoneGap, what PhoneGap is, we actually have to ask ourselves the question, hey Jeff, what can I do with PhoneGap? Can I use it for Android and iPhone? It actually supports seven different platforms all with one code base. What about selling it? I really want to sell it. Can I sell it? Because it's a native app, you can actually sell it on all the app stores. And what about offline content? I really need to have some pages like in about us, page terms and conditions, et cetera. I need those to be always there in the app even if the user has no internet access. Can I do that? Actually, all you need to do is just copy those into a www folder. It gets packaged up with the app and it's just sitting on their phone waiting for them to use it. Okay, now that we have the online content, what about the offline content? What about the online content? I really want to have the news from my website featured in my mobile application. What would be a way to do that? Probably the easiest way to do that is set up services on Drupal. You can do that with Drupal 6, you can do it with Drupal 7. Take a look at services three. It's actually pretty easy just to make all the nodes that you want up and available to your users, to your mobile phones, to your Android's, iPhones, mobile web, put in that services layer and all the phone gap apps can start talking to your Drupal server and get fresh content. Okay, but what about those native features I've heard about? What does phone app support? What can I do with it? So the great thing about phone gap is that it's extensible. So right out of the box, it comes with plugins for the camera, push notifications, contacts, plugins, maps. It's really cool. One of the great things about phone gap is that you can extend it. So if there's new parts of a native app that you want in your phone gap app, you're not limited, you're not stuck. You can always just code those up as sort of a native app style, get those into your phone gap app and you're good to go. Oh wow, and this is now the matrix. So you really don't have to know all this, but it's just showing that phone gap supports tons of features across tons of platforms. So let's check our requirements from the beginning again of what our client wanted from us. So have we fulfilled our requirements? You know, I could go back to that big ugly screen, but I think I remember enough of it. So let's see, we have Android and iPhone, it's for sale, offline content, online content, and we have those native device features. Yes, I think we can use phone gap for the build out, but before we going into building that, we want to quickly give you some hints of when better not to use phone gap. So if you want to create a game and it needs to have really high performance and lots of graphics and needs to be really fast, phone gap is not what you use. You really want to use the native application. And when you don't need any of those native features, the offline content, or the possibility to put it on a market, then you could end up being better but just creating a web application with a mobile scene that kind of would give you the same and then phone gap is kind of overkill and just too much. And if you just want to display something mobile, you can just use a responsive design, make a mobile site, and you don't have to fiddle with native features. But as we will see later, it might be possible to just combine those two. And that's what we come to now meet mobile app generator. It was published today or better, this is the publishing Drupal.org project MAG. It's an extension to hybrid apps. You know, normally those apps are created in the following way. You create the app and you connect it with services. And you have to learn all those mobile frameworks, jQuery mobile. And for example, you now already made a site, it has a nice mobile scene, and now you have to rebuild all of that again, build it all in JavaScript, connect it with the services, et cetera. While sometimes you just want to use what you have as your Drupal skills, what you are already now, what you are using, and you just want to make this into an app. And this is what the mobile app generator really allows you to do. You can create your app completely in Drupal, just a mobile site, you can test it online, you can integrate it with services, and then with a click of a button, you export it for PhoneGap, you get a nice folder, you plug it in, you can test it on the device, and it all works. And so what before took like, I don't know, many, many, many hours of extra development to kind of get your Drupal site connected with your app, you can now use your mobile site and export certain things to it in just five minutes. So this is what we now want to see, how we kind of can use this mobile app generator. It's demo time, so let's go.  And this is what we want to take a look at now. So this is a mobile site, as you can see, and it has some nice menu, it's a jQuery mobile site, it has some images, and you can see it's, from the admin interface, it's just a normal Drupal site with some mobile theme. And it has, at this moment, nothing to do with kind of native features, PhoneGap, or anything like that. But now, if you want to export it, it's actually quite easy with your mobile app generator, we just select it from the menu, and then we can set up a path. At this point, I just set a path of sites all export, because I really want to make sure I can use it in my Git repository and edit there. But you are, of course, free to use any file scheme that Drupal supports. So you can even export it directly to S3 and run it from there. Can also help with performance. And then we have a Regex for saving those directorates, because it was the case that some modules were just not advertising all of the images and JS. And last but not least, we select the main menu, we save our configuration, and we generate the mobile app. Selecting the menu is important because we really are only exporting what is in that menu. And all other pages are kind of going to an offline page that says, if you want to see, just go to our normal website. So it's generated quite quick, and here it is. As I said, not even five minutes. You can start it up, and there you go. And as you can see from the header at the top, it's just static HTML pages, which are all exported now and would work nicely with PhoneGap. So we have those images in. It has detected all the assets of the web page, and kind of that's it. And what I would like to encourage you is, you've got homework now. You've all got to try this out at home. So the next part is how to actually get this into PhoneGap, and this is where I give back to Jeff. So with PhoneGap, you have a couple different choices for actually creating your app. If you're on a Mac, you can create apps for iOS, the iPhone, the iPad. You'll need to install Xcode, which is Apple's developer tools. Those are actually free right now on the Mac App Store, but you'll need a really recent Mac with a really recent version of the Mac OS X. And they're constantly pushing that Xcode stuff out to the latest and greatest Mac. So iPhone and iPad development though is only from a Mac. If you have a Windows or a Linux or a Mac, you can actually develop apps for Android using Eclipse and the Android SDK. You'll need to get those set up. The best place to do that is to just go to Google's Android site and click install the Android SDK and they have some pretty good directions in there. Once you have your development environment set up, you actually need to download PhoneGap and they have an excellent set of installation instructions no matter whether you're developing for Android or for iOS or for Windows Phone. They actually did a really good job of making that easy.  And then all you need to do is create a new PhoneGap project for iPhone or Android from that development tool and you'll pretty much have a PhoneGap project up and running and that's an app right there, out of the box. So let me just show you a really quick PhoneGap project. So to create a new PhoneGap project, all I would need to do from this Xcode and this is that Apple developer tool I was talking to you about, about how to create iPhone and iPad. Just go to New Project, pick PhoneGap, click Next, we'll call it Drupal is awesome, save it. And that's a PhoneGap project. I already have one set up for DrupalCon right here and what I can do is show you what Fabian's mobile app generator actually looks like when you're running on an iPhone. And so there's that exact same mobile site that he just showed you how to create and now it's actually running as an iPhone app. This little iPhone simulator here is actually just the same as your iPhone that you're holding in your hand and so you can see how it works. I can actually take that same one and turn it into an iPad app and there's the exact same site but now running on an iPad instead of an iPhone because we set this up with jQuery mobile that actually takes care of the whole MI and iPad, MI and iPhone. You actually have both in one app in one site that was just sort of created for you in five minutes. So I'm gonna go back to presentation. And there's even a little more. As Jeff already said, some people might not be on a Mac and they still want to try to create iPhone apps or iPad apps and there's actually a solution for that. What not too many people now is there's PhoneGap build. It's the PhoneGap cloud, build.phonegap.com and in this case, you would just upload your generated WWW folder via Git to the PhoneGap cloud and it's actually completely free for public apps. So if you're kind of in a sector where you can publish everything and have everyone have access to the data directly, you can use it for free. If you use it commercial, you got one app free, the rest costs. The nice thing about the cloud is that it allows you to build directly for seven platforms which saves really much time because you might not have the BlackBerry environment, the Windows Mobile environment, the whatever new mobile solution is coming out tomorrow environment. So the next part we want to talk about is how you can now actually use PhoneGap with the native features. And Jeff will now show an example of how good this works with the camera. So one of the things that I've always heard people talk to me about when they want to talk about PhoneGap and Drupal is that they want to take a picture on their iPhone and then upload it to their Drupal site. And that's actually really easy with just JavaScript and PhoneGap. So you don't need to learn any crazy languages. You don't need to get really deep into image processing or something like that. It's actually just a couple lines of JavaScript that basically came right off the PhoneGap documentation. So here's the JavaScript you need to basically take a picture with the phone and then just put it into an HDL image inside your mobile web. So it actually makes things like taking a picture really straightforward using just straight up JavaScript. Another thing that you might need is especially with having online and offline content the ability to know if a device is actually connected or if you're at offline. And again, PhoneGap shows how easy this is to use because you can, you just add an event listener via the normal JavaScript API and on online function and here we are just setting up a little alert. There's also more functions in the PhoneGap API that's pretty well documented and easy to understand with some basic JavaScript knowledge where you can, for example, detect if you're on a wireless or if you're on a 3G or just on a mobile data plan and whatever the device is really giving to PhoneGap but especially the difference between being on a wireless or where you could show a movie and being just on a slow connection where you better should not, can be quite beneficial. Next we want to show you some tricks of how to develop your PhoneGap apps. The first thing to think here is do really not try to develop on a device. You will have to do some code, click the button and you have to wait, then you check it and you don't really have that good development and debugging tools as you have in the web browser. So if you are especially developing for iPhone and Android use any web kit based browser that would be Chrome or Safari and if you use one of those two, it usually will be that your app will on the phone be exactly looking like in the browser. So that's definitely a trick I can give you. And also do the testing and debugging in the browser. It says the JavaScript error and you're putting it into the iPhone simulator. You might see it, but it might be a little more difficult to debug. The other thing is now I said you should really test on a browser, but afterwards you need to test on real devices. In my experience, it sometimes came up that it was all working nicely and shiny in the browser and then you were testing it on a real device and then you were going with your phone to somewhere else where you were not in your home network and suddenly it broke. So it's really as important to make sure that you do a real test before going to the market because users will notice and they will be the first to complain with the stars. So and actually when I built my first phone gap app I didn't have an iPhone. So what I did was I did go to some store and I was asking them, hey there, could I just check out this app for a moment? It worked. Another thing is, especially with phone gap clients could get kind of the idea of, oh, we will just build the app for all of those seven platforms, directly and everything. But especially with BlackBerry, I was in another store and it didn't work. So you need to test extra for those platforms and if your client really wants to do that, it might be beneficial, or if you want to do it, it might be beneficial to just get the BlackBerry emulator. The same is true for Windows Mobile because it has not the same WebKit engine so rendering could be different, JavaScript could be different and they are all of those little quirks that can come up here. And Jeff here has something really nice. He has a Drupal plugin for phone gap. So if you want to dive a little bit deeper into phone gap and you want to talk to Drupal using the Drupal iOS SDK, I wrote a little plugin that really is just a bridge between the Drupal iOS SDK and phone gap to let you use JavaScript to access some Drupal services.  That's all up on that GitHub there and there's also a cool little simple project that lets you use the camera and jQuery mobile to upload pictures up to a Drupal site. So check that out if you want. Another thing that is really, really handy when developing now you want to test with a real device is a little trick I'm using, especially when I'm using the mobile app generator. So in phone gap you have a setting that's called, especially for the iPhone SDK, it's called external host. And this really means it's a white list where you can specify what kind of hosts are white listed. And those white listed hosts won't start up a new browser, but actually it would start in the same web kit. And now what you can do, if you're kind of developing your site locally on the local host, you can just add this function on device ready with location.arrich, HREP, and you can just forward to your mobile app. And in that way, you don't have to rebuild your app again and again, but you can just change it in your web browser and in your normal environment and then you can even test it on the SDK again, again, again. And really with phone gap and especially also the mobile app generator that we have introduced here today, it's really important that you play around. As I said, this is your home book. It can be really fun, you know, this experience when your app finally is running on this phone and you can download it from the market and user comments are coming in and the reviews are coming in and you are like, wow, that's great. Or think about your favorite restaurant or so. They might already have a website, they might already have a mobile site, but now you could provide them with a little effort and just creating this folder with some mobile app generator. You could provide them with a mobile app as well. And I heard more and more that just local restaurants, local businesses, they all want an app. So this is really an opportunity here where you can do really fun stuff and nice things. We are already at the questions part. We could also demo a little more. That would be also a possibility. But I think let's start with questions. Well, let me ask a real simple question. Could you drill in a little bit on the first part where you built your site in Drupal and then generated HTML and so on? But you used a mobile theme, because I haven't done this before, are there mobile themes available on Drupal.org? How much do you need to know of Jake Berry to do this? That's a really, really great question. And actually I was shocked because I was preparing the presentation and I was saying, okay, I'll just choose any of the available mobile themes on Drupal.org. And I was finding three that kind of looked like something from the start on. And I didn't have to put in a lot of effort to have it look like a mobile web application. One of them was just a theme looking mobile, but not really application-like. The other one is the Nokia theme that's just available for Drupal 6. So really what in the end came out is this is a Jake Berry mobile theme.  I had to fix, I think, three bugs to prepare for the presentation. I put them later in into the issue queue, so that should be taken care of and you can really use it. And the other thing I did install is a Jake Berry mobile UI, but fixing those bugs and putting in the Jake Berry mobile UI and enabling the theme was basically everything I did to just have it looking like this. Before it was garland with the menu at the top and the notes below, I enabled the theme and it was looking like this. And yeah, I hope this answers the question. Hello? Do you guys support speech recognition on this or any plans for it? So the question was about speech recognition. As far as I know, you would have to support that with some sort of native library. I don't think that iOS comes with a good one if it comes with one. I don't know about Android, but it's certainly not part of the standard phone gap API. From what I understand, you have to license some very expensive libraries to get sort of like Siri-type speech recognition into your app. Thanks. Hi. My question is about analytics. Is there a connection to Google Analytics or I don't know what's in the iOS? So that actually raises an interesting point. As I was doing some research for the Drupal mobile guide as part of the Drupal 8 mobile initiative, there's actually a special plug-in for Google Analytics for Jake Berry mobile to make sure that when users hit the pages because everything's through Ajax that a Google Analytics gets recorded. So you'll actually get, if you have a Google Analytics module, then it should be recorded. There's other ways to get analytics from a native app, but that probably makes sense to integrate everything with Google Analytics for your desktop web and your mobile web and your phone gap app. Does that answer your question? Two questions about offline content. Sure. First is, can I download just a subset based on some criteria? That's exactly what a mobile app generator is doing. It's only exporting a subset and you define the subset by defining the menu. In this case, I just had the main menu and this was actually also the menu you were seeing, but you could also define a hidden menu with lots more content and it really is exporting everything you specify and what's not exported is going to an offline page which you define as an offline alias, for example, and then the user hits this offline page and they can write something like, well, this page is not available in the app, but if you want to know more, you can visit our web presence here and get more information. By content, can that be a content type of various sorts? Could you repeat, I didn't get? Could the content download be a content type like an article, for example? At the moment, the content is supporting nodes, but it would be very easy to also support other entities. For ease of use, it was made with nodes, but it could be easily extended, but it's not content type. We had an article there, we had a page there. You can specify whatever criteria you want. You just have to create the menu. My second question is, if I make a change offline, does it sync back to the main site? No, you shouldn't do changes offline. You should do changes online and to regenerate your app. In that case, the workflow would be working like this. You would just regenerate it into the same directory. It would override with the new data, and then what you would do is kind of, you would drag this folder again into PhoneGap or use your version control system to do it. But if you want to have online content, kind of, then you would use services here. Three very quick things. One, this was an awesome presentation. Thank you guys. Excuse me. Two, the menu position module that John Albin did would be really cool if it was integrated with this so that I could say all articles under this menu position would get converted over to mobile. Just a thought. That's a very good idea. If I do menu three, would I get, is it hooked in there? I'm not sure on the details, but I think it's called menu position. I know the module. I'm just thinking about where it hooks in, kind of, okay, that's a little technical for beginner. But yeah, that's a very great idea because that would allow a lot more flexibility. You could put a taxonomy term on anything, call it mobile, and then. Definitely, and then it would kind of auto generate your menu, which would give it a lot more flexibility. But yeah, I believe it should work. And number three, how does it handle user sessions? Can I have, for example, people log in or create an account using this system? In general, the exported pages would not kind of be online, but PhoneGap in itself, you can log in very easily. You want to talk a little about that because you have said. Sure, actually, so the way you would do that is to use the services API, and you can actually use System Connect, user log in, user log out, and then you'll have an authenticated session. Be sure in services to enable session authentication for your endpoint or it'll get these annoying errors. But it's definitely very, very possible, and that's actually how that camera app works on my GitHub is, you know, you log in as Joe Schmo or whatever. Hi guys, nice presentation, I echo that. I'm not a coder here, but the developer I work with developed an application, it's in a mobile application right now that it's using, it's a content type with views to like generate restaurants. You know, you could set like Asian restaurant or whatever in it, could that be exported? I mean, could that be brought in? And then I know, I mean, how's the data updated? When they go and update it something, you know, one of the items in Drupal, like a new restaurant or change a phone number or something, how would that happen? Yeah, you always, the point is, and that's kind of the nice thing about it, you build your app kind of in the way you want. So if you have a block where you say this one should always be logged via Ajax, you could use any of the Ajax load modules, and the mobile app generator would just generate your app, but the JavaScript for reloading the Ajax would be there, so it would actually try to load the block, and you could for example, just have a placeholder in there or the older information, just have it in there, then you use Ajax load or Ajax block or what is called or just some custom JavaScript code to actually reload the view, and then you could kind of have an app that's kind of, if it's online, has newer information than if it's offline, but usually in this case, kind of how apps would be updated would be through the app store. So we are also working on the approach that kind of you do an update online and the app is kind of downloading those updates, but it has some tricky bits, like for example, sync of a view, which is on one page and on the other as well, and then you have to update all of the pages, which could be a rather huge download. Thank you. I guess along the same line of what we just talked about, to create an experience like we have of the DrupalCon app where it has the sessions and knows what sessions there are and then you can press refresh. Is that like something that your module could support? It doesn't sound like it would be like a SQL store, local, something. You're mainly talking about kind of online content or synchronizing content. There was kind of also what I was going in the previous question, but it's a little different here. The DrupalCon app, as far as I've used it, you're not updating it over the app store, but it's kind of downloading the data, which you could do and that's supported. I have such running in kind of another approach, which is similar to the mobile app generator and will be combined with it later, but not just now, is you could, for example, do the following. You just put it on S3 like we've seen as that's possible and then you add a little code to your JavaScript. With PhoneGap, you have a file API. So what you could do is kind of, you could create a folder where you are downloading all the stuff and when you're sure that you have all the files, you just switch over. But kind of, if you just want to update information, kind of just reload things, I think it might be kind of better to use services for that at that point. Yeah, that makes sense. The second question I had was, does your module support the ability to create a different experience by serving two different themes, one for the iPhone, one for the iPad, for example? Or how would you do that? That kind of depends. Okay. If you're using a responsive design, for sure, because kind of the same rules to apply, you get kind of the responsive device with features and their Jaguar mobile, of course, also helps completely. But if you're talking like, if the user agent is an iPad, then you get this side. If the user agent is a mobile side, then you get this side. But what you could do is kind of, okay, that's still manual, but it's two clicks. You change the theme to mobile and you change the folder to WWI phone, export, change the theme to iPhone, WWI iPad, export, and you just create two separate apps. Awesome, thank you. In the case of, in the case of, say, user-generated data, sounds like PhoneGap is best if data is pushed from Drupal to the user. But in terms of, say, the user-generated data, account statuses, or, say, geolocation check-ins, is PhoneGap better, or is it an effective way to go over native? And would that something be done through, say, services and APIs? So PhoneGap itself lets you use services. You can do pretty much anything you want in PhoneGap in terms of connecting to an outside system. So if you wanted to do check-ins or create comments or something like that, you could absolutely do that. You would just simply create either an HTML form that talked directly to Drupal. I mean, that's the easiest way to do it, is actually in PhoneGap, say, hey, you know what? I need a live connection anyway to get a comment. Throw up a mobile-themed ad comment, ad node page on your Drupal site. You don't have to write extra JavaScript. You don't do anything extra. You've kind of got that right there. You've got everything built in. That's probably the easiest way to do it. The other way to do it is to make a JavaScript call and basically back up to services and say, hey, services, here's a new comment for this node or what have you. Does that answer your question? Yes, thank you. I also would like to kind of extend a little in regards to the mobile app generator. What's nice about just exporting a subset is that, for example, before we just removed it, but before you had this ad new comment on the article content type, so what you could do now is you could have the same app that's running in PhoneGap online and you could just switch the user over from his offline experience to an online experience by letting him logging in, posting commands and just having kind of as a mobile app generator is not touching the URLs, for example, for posting commands, that would still work and you could would kind of post it there and then we would get the response and then the only thing kind of you need to do is kind of to get back to the offline part. But I think on the online part that would be just some lines of JavaScript code or even a form state, but there would be kind of future back, but it's interesting. Thank you gentlemen, you've given us all lots of homework. Thank you. Great presentation, I love the battle at the start. My question is you mentioned titanium as a hybrid at the top. Can you talk about advantages and disadvantages of that versus PhoneGap? I can't. So I'm not a titanium developer, but I am a native developer, so I usually develop in Objective-C myself. Titanium is a great solution if it supports your needs in advance. So you have to do a little bit more research to make sure that what you're trying to do is easily done in titanium, but the big advantage of titanium is you get one code base for both iOS and Android. The downside is that while it does compile to a native app, you don't necessarily get every native feature right away when Apple releases it, but I know that the company behind titanium is putting a lot more effort into making that development really easy for people. For those of you who aren't aware of what titanium is, it's a way of creating iOS and Android apps in pure JavaScript, talking to the titanium API, and then that actually creates an iPhone app or an Android app from one JavaScript code base. So does that kind of answer your question? It's a very different approach from PhoneGap. Yeah, thanks. Would the mobile app generator support web forms through the export, or would you have to do something extra to get that submission to post to the site? As I said, if you have a web form is a content type, so yes, at the moment, I haven't tried it. Short answer, long answer. I believe what would happen kind of is that the site would be exported, but that the post URL was not changed, so it would still connect to from where you kind of generate the app. And if you're not generating from local host, but kind of from your life side, this means which will still be fast because it's all online on the web server that's done the creation of the app, which means that probably it would just post to the website, but the problem is you are then online. You would still need to put your online URL into the white list. And kind of the same answer as before, you would need to add some, just some custom JavaScript on the submission succeed page to just get the user back to an offline submission succeed page. So that should be quite easy to do, especially with my form. First, I want to say thanks for releasing the module. That's an awesome start. That's great. So I want to give you this. Two specific questions I've been starting to develop with this stuff, and maybe this is future development. Look into, have you done anything with ghost clicks and using the A object tab tags versus like a different tag and replacing links? I didn't forget the question quite. Have you heard of what's called ghost clicks when you're developing with PhoneGap? Nope. Oh, it has to do with the browser doing something three to milliseconds after you click because they're waiting to see if you do a second click like a double tap versus a single tap. Mm-hmm. So I was just curious if you'd done anything to replace the AHA ref tags with something else. Actually, this is taken care of by mobile frameworks. This is normally nothing to do with PhoneGap. I know of the problem, but JQTouch, JQuery Mobile, CentralTouch, they kind of all have solutions for that for replacing the click event with the touch event. That's basically everything you need to do to kind of get this to work in that. In the PhoneGap, kind of for exporting things, I'm using an approach very similar to the CDN module and Boost modules that were kind of the parents of the idea for doing that and for kind of getting everything out plus some dirty tricks. So a real quick one. So I went to the project page and the project is up there, but there don't seem to be any releases published yet? I pushed the release to day morning. I was under the impression that a release, if I pushed it, is kind of coming up on the next corn run, but what you can do to check it out already is you can hit the revision tab and you can just check out the 7x branch. It's still telling me no release is available, but we'll find it. Yeah, anyone find a webmaster of Drupal and he can push the release out? Do you know offhand whether PhoneGap supports access to the calendar on the phone? Take a look at the matrix, right? I didn't see anything listed for calendar on the matrix. That's what I was asking. I think you're correct. It is not supported and that's probably simply because the vendors themselves don't have that as one of the things they provide access to. So it's not really PhoneGap's fault. If I'm writing a regular iPhone app, I probably don't have access to that either. If that helps, answer your question. Okay, thanks. And I think we have time for one more question and we have, here's the lucky... It's a super quick one, I think. I just installed it and used it and it worked great. That's fantastic. Wow, great. Does it only publish the pages under the menu item that you specify on the config screen to actual flat HTML files? Does that make sense? Yes. On the export file, like I just had an empty sandbox, there was only index. So do I need to add menu items to that parent menu item to get them to publish to flat files on the export? Everything you need to... Could you repeat the question a little? What I had in the menu is I had the front page in there. So it could be if you're not having the front page in the menu that it does not work. That might be a possibility. I just ran into Vell and it made a bunch of nodes without menu entries and they didn't export out as flat files. Is that because they didn't have menu entries? Yes. It'll only export pages that exist in the menu. Yes, but as I'm quite dumb about the menu, it could be because I'm not checking the hidden flag or so that you can just hide the entries in the menu. And as the other person said, it might work with menu location and if it doesn't work yet, it might be very easy to implement just to have it work with taxonomy or whatever. But really, there's just one function that's kind of, it's three lines of code that's doing this exporting via menu and it could be easily extended. Contributions are welcome, of course. Well, it works great. Thanks a lot. So thanks a lot for attending our presentation. It was a great Q&A session. I'm Fabian Franz from TreloN. You can follow my posts on TreloN.com slash blog or on GitHub, Fabian Franz, Twitter at Fabian Franz. Same basically for me. You can follow me at JeffLinwood.com or GitHub, JeffLinwood or Twitter, JeffLinwood or pretty much anything else, JeffLinwood. Find me there. Yeah, and I want to thank the company TreloN for really sponsoring development of the mobile app generator. Please vote on the session for the mobile tournament 2012.