Let $\times$ represents a girl and $o$ represents a boy.
Then, first place the girls as $ .\times . \times.\times.\times.\times.\times.$ where $.$ represents $o$ or no one. Now , Since John is at extreme, he has two choices while other $4$ boys have $6$ choices giving total of ${2\choose 1}{6\choose 4}$. Now permute all the boys independently(except John) and girls independently giving total of ${2\choose 1}{6\choose 4}4!6!$ sitting arragements.
I think it is explained in your OP. We do the same thing with a bit more detail.
Since we have already counted the number of "bad" positions with all the boys together, it remains to count the number of bad positions in which the boys are not all together, but some boy is not next to a girl.
There must be two boys together, and they must be at the left end or the right end ($2$ choices). Take such a choice, say left end. Then the remaining boy can be in any one of $3$ places, namely positions $4$, $5$, or $6$. That gives us $(2)(3)$ ways of choosing the seats the boys will occupy. For each of these $(2)(3)$ choices, there are $3!$ ways of permuting the boys among the chosen seats, and for every such choice there are $3!$ ways of permuting the girls, for a total of $(2)(3)(3!)(3!)$.
Another way: Counting all possible arrangements and subtracting the "bad" ones is often good strategy. But let us count directly.
Our condition will be satisfied if either no two boys are together, or exactly two boys are together and they are not in the end seats.
Count first the arrangements in which no two boys are adjacent. Write down $G\quad G\quad G$. This determines $4$ "gaps" into which we can slip the boys, one boy per gap. There are $4$ "gaps" because we are including the end gaps. There are $\binom{4}{3}$ ways of choosing $3$ of these gaps.
Or else we could slip $2$ boys into one of the two center gaps ($2$ choices), and then slip the remaining boy into one of the $3$ remaining gaps, for a total of $6$ choices.
Thus the places for the boys can be chosen in $10$ ways. For each of these ways, we can arrange the boys is $3!$ ways, and then the girls in $3!$ ways, for a total of $360$.
Best Answer
Another way is to observe, as you did, that there are $4$ legal arrangements of the letters $b$ and $g$. For each of these arrangements, the boys can be placed in $3!$ ways, and for each of these placements, the girls can be arranged in $3!$ ways, for a total of $(4)(3!)(3!)$.
That way of thinking about things might be useful if instead we want, for example, the number of arrangements that have a girl at each end.